text
stringlengths 1
93.6k
|
|---|
###############################################################################
|
def lasclip2(inputs, shp, odir, nodata=0, prefix="", rejectinterior=True):
|
'''clip a laz file using a shape file'''
|
# odirlog = makedirs(odir)
|
cpu = getcpucount(0)
|
strcores = " -cores %s" % (cpu)
|
odix = "_clipped"
|
#decide if we are to keep the point inside or outside the area.
|
if rejectinterior:
|
rejectinterior = " -interior"
|
else:
|
rejectinterior = ""
|
# filename = os.path.abspath(filename).replace('\\','/')
|
# root = os.path.splitext(os.path.basename(filename))[0]
|
# outfilename = os.path.join(odir, prefix + '_clipped.laz')
|
# outfilename = os.path.join(odir, prefix + root + '_clipped.laz')
|
# outfilename = outfilename.replace('\\','/')
|
shp = os.path.abspath(shp).replace('\\','/')
|
cmd = "lasclip.exe" + \
|
" -i %s" % (inputs) + \
|
rejectinterior + \
|
" -cpu64 " + \
|
" -donuts " + \
|
strcores + \
|
" -quiet " + \
|
" -olaz " + \
|
" -drop_x_below %s" % (str(10))+ \
|
" -poly %s" % (shp) + \
|
" -odir %s" % (odir) + \
|
" -odix %s" % (odix)
|
# " -o %s" % (outfilename)
|
stdout, stderr = runner(cmd, False)
|
return
|
###############################################################################
|
def demzip2(filename, outfilename, nodata=0, replace=False):
|
'''convert the 1-band tif file to a laz file '''
|
odir = os.path.dirname(outfilename)
|
odirlog = makedirs(odir)
|
#the file already exists and the user is not wanting to replace...
|
if os.path.exists(outfilename) and replace == False:
|
return outfilename
|
if os.path.exists(outfilename) and replace == True:
|
fileutils.deletefile(outfilename)
|
cmd = "demzip.exe" + \
|
" -i %s" % (os.path.abspath(filename).replace('\\','/')) + \
|
" -nodata_value %s" % (str(nodata)) + \
|
" -olaz " + \
|
" -o %s" % (outfilename.replace('\\','/'))
|
stdout, stderr = runner(cmd, False)
|
return outfilename
|
###############################################################################
|
def demzip(filename, odir, nodata=0, prefix="", replace=False):
|
'''convert the 1-band tif file to a laz file '''
|
odirlog = makedirs(odir)
|
root = os.path.splitext(os.path.basename(filename))[0]
|
# outfilename = os.path.join(odir, prefix + '_1band.laz')
|
outfilename = os.path.join(odir, prefix + root + '.laz')
|
#the file already exists and the user is not wanting to replace...
|
if os.path.exists(outfilename) and replace == False:
|
return outfilename
|
if os.path.exists(outfilename) and replace == True:
|
fileutils.deletefile(outfilename)
|
cmd = "demzip.exe" + \
|
" -i %s" % (os.path.abspath(filename).replace('\\','/')) + \
|
" -nodata_value %s" % (str(nodata)) + \
|
" -olaz " + \
|
" -o %s" % (outfilename.replace('\\','/'))
|
stdout, stderr = runner(cmd, False)
|
return outfilename
|
###############################################################################
|
def lasindex(inputs, rebuild=False):
|
'''index the laz files for performance'''
|
inputs = os.path.abspath(inputs).replace('\\','/')+"/*.laz"
|
# log('index the laz files for performance')
|
odir = os.path.dirname(inputs)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.