From fcc6b810c8ca212392e9fe30c6f8b71e51351e3e Mon Sep 17 00:00:00 2001 From: Dan Howe Date: Tue, 11 Sep 2018 15:13:09 +1000 Subject: [PATCH] Use temp files instead of stdout piping, to support older lastools versions --- las_manipulation.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/las_manipulation.py b/las_manipulation.py index 7fc5357..7f3adbf 100644 --- a/las_manipulation.py +++ b/las_manipulation.py @@ -387,25 +387,22 @@ def process(yaml_file): # Get base name of input las las_basename = os.path.splitext(os.path.basename(input_las))[0] - # Crop to beach boundary + # # Crop to beach boundary print('Clipping...') - las_data = call_lastools('lasclip', input=input_las, output='-stdout', + las_clipped_name = os.path.join(tmp_dir, las_basename + '_clipped.las') + call_lastools('lasclip', input=input_las, output=las_clipped_name, args=['-poly', initial_crop_poly], verbose=False) # Classify ground points print('Classifying ground...') - las_data = call_lastools('lasground_new', input=las_data, output='-stdout', + las_classified_name = os.path.join(las_dir, las_basename + '.las') + call_lastools('lasground_new', input=las_clipped_name, output=las_classified_name, args=['-step', lasground_step], verbose=False) - # Save classified point cloud - las_name = os.path.join(las_dir, las_basename + '.las') - with open (las_name, 'wb') as f: - f.write(las_data) - # Interpolate point cloud onto a grid print('Interpolating to grid...') xyz_name = os.path.join(tmp_dir, las_basename + '.xyz') - call_lastools('las2dem', input=las_data, output=xyz_name, + call_lastools('las2dem', input=las_classified_name, output=xyz_name, args=['-step', 1], verbose=False) # Make runup clipping mask from gridded point cloud