Add verbose option for lastools messages

etta-drone
Dan Howe 6 years ago
parent c09dad993c
commit cee13119c7

@ -2,7 +2,7 @@ import os
import subprocess import subprocess
def call_lastools(tool_name, las_in, las_out=None, args=None): def call_lastools(tool_name, las_in, las_out=None, args=None, verbose=True):
"""Send commands to the lastools library. """Send commands to the lastools library.
Requires lastools in system path. Requires lastools in system path.
@ -12,6 +12,7 @@ def call_lastools(tool_name, las_in, las_out=None, args=None):
las_in: bytes from stdout, or path to input point cloud las_in: bytes from stdout, or path to input point cloud
las_out: '-stdout' to pipe output, or path to output point cloud las_out: '-stdout' to pipe output, or path to output point cloud
args: list of additional arguments, formatted for lastools args: list of additional arguments, formatted for lastools
verbose: show all warnings and messages from lastools (boolean)
Returns: Returns:
bytes of output las, if las_out='-stdout' bytes of output las, if las_out='-stdout'
@ -24,7 +25,7 @@ def call_lastools(tool_name, las_in, las_out=None, args=None):
args=['-parse', 'sxyz']) args=['-parse', 'sxyz'])
# Clip las_data with a shapefile, and save to a new las file # Clip las_data with a shapefile, and save to a new las file
call_lastools('lascrop', las_in=las_data, las_out='points.las', call_lastools('lasclip', las_in=las_data, las_out='points.las',
args=['-poly', 'boundary.shp']) args=['-poly', 'boundary.shp'])
""" """
@ -66,6 +67,10 @@ def call_lastools(tool_name, las_in, las_out=None, args=None):
os.path.basename(las_in))) os.path.basename(las_in)))
print(stderr.decode()) print(stderr.decode())
elif verbose:
# Print addional messages if verbose mode is being used
print(stderr.decode())
# Output piped stdout if required # Output piped stdout if required
if las_out == '-stdout': if las_out == '-stdout':
return stdout return stdout

Loading…
Cancel
Save