text
stringlengths 1
93.6k
|
|---|
try:
|
fileutils.deletefile(filename)
|
os.rename(outfilename, filename)
|
except:
|
log("Error while duplicating & renaming file %s" % (outfilename), True)
|
return filename
|
###############################################################################
|
def hillshade(filename, odir, resolution):
|
'''make a hillshade png file for QC purposes'''
|
odirlog = makedirs(odir)
|
filename = os.path.abspath(filename).replace('\\','/')
|
root = os.path.splitext(os.path.basename(filename))[0]
|
outfilename = os.path.join(odir, root + '_hillshade.png')
|
outfilename = outfilename.replace('\\','/')
|
cmd = "blast2dem.exe" + \
|
" -i %s" % (filename) + \
|
" -drop_x_below %s" % (str(10))+ \
|
" -step %s" % (str(resolution)) + \
|
" -kill %s" % (str(resolution*10)) + \
|
" -hillshade" + \
|
" -opng " + \
|
" -o %s" % (outfilename)
|
stdout, stderr = runner(cmd, False)
|
return outfilename
|
###############################################################################
|
def lasclipbb(filename, rect, odir, resolution, nodata=0, prefix=""):
|
'''clip a laz file using a rectangle file'''
|
#-keep_xy 630000 4834000 631000 4836000 (min_x min_y max_x max_y)
|
odirlog = makedirs(odir)
|
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 + '_G_C.laz')
|
outfilename = outfilename.replace('\\','/')
|
#ensure the las file has positive up. some files are positive down. this is not so good so we can find out if the file has positive depthas and set blast to invert them on the fly
|
scale_z = 1.0
|
lasrect = getlazboundingbox(filename, odir)
|
if ispositivedepths(lasrect):
|
scale_z = -1.0
|
cmd = "blast2dem.exe" + \
|
" -i %s" % (filename) + \
|
" -keep_xy %.3f %.3f %.3f %.3f" % (rect.left, rect.bottom, rect.right, rect.top) + \
|
" -drop_x_below %s" % (str(10))+ \
|
" -scale_z %s" % (str(scale_z)) + \
|
" -step %s" % (str(resolution)) + \
|
" -kill %s" % (str(resolution*100)) + \
|
" -olaz " + \
|
" -o %s" % (outfilename)
|
stdout, stderr = runner(cmd, False)
|
return outfilename
|
###############################################################################
|
def lasclip(filename, 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)
|
#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" % (filename) + \
|
rejectinterior + \
|
" -cpu64 " + \
|
" -donuts " + \
|
strcores + \
|
" -quiet " + \
|
" -olaz " + \
|
" -drop_x_below %s" % (str(10))+ \
|
" -poly %s" % (shp) + \
|
" -o %s" % (outfilename)
|
stdout, stderr = runner(cmd, False)
|
return outfilename
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.