From 144f93569879425d510192040b773e55b9122c63 Mon Sep 17 00:00:00 2001 From: Dan Howe Date: Mon, 9 Jul 2018 10:05:25 +1000 Subject: [PATCH] Fix repeated shp extension --- las_manipulation.py | 2 +- outputs_2017088_Survey2.py | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/las_manipulation.py b/las_manipulation.py index a35caf5..2739730 100644 --- a/las_manipulation.py +++ b/las_manipulation.py @@ -326,7 +326,7 @@ def polygon_wave_runup(xyz_1m, direction, shp_name, set_check_value, distance_ch # Export polygon as shapefile df = gpd.GeoDataFrame(geometry=[Polygon(for_shape)]) df.crs = {'init': 'epsg:283{}'.format(zone), 'no_defs': True} - df.to_file(shp_name + '.shp', driver='ESRI Shapefile') + df.to_file(shp_name, driver='ESRI Shapefile') return None diff --git a/outputs_2017088_Survey2.py b/outputs_2017088_Survey2.py index 661d0b3..9de895c 100644 --- a/outputs_2017088_Survey2.py +++ b/outputs_2017088_Survey2.py @@ -23,6 +23,8 @@ import xlsxwriter import math from cycler import cycler +from survey_tools import call_lastools + ############################################################################### ########################## FIXED INPUTS ####################################### ######### UNCOMMENT THIS SECTION IF YOU WANT TO DEFINE EACH INPUT INDIVIDUALLY ###################### @@ -359,17 +361,19 @@ def remove_temp_files(directory): ############################################################################### ########################### RUN CODE ########################################## +input_file = 'Parameter Files/las-manipulation-survey-2.xlsx' params_file=pd.read_excel(input_file, sheet_name="PARAMS") for i in range(0, len(params_file)): #0, len(params_file) print("Starting to process %s" % params_file['Beach'][i]) beach=params_file['Beach'][i] survey_date=params_file['SURVEY DATE'][i] - input_las5=params_file['INPUT LAS4'][i] - crop_swash_poly=params_file['CROP SWASH POLY'][i] + original_las=params_file['INPUT LAS'][i] + classified_las_dir=params_file['LAS CLASSIFIED FOLDER'][i] + shp_swash_dir=params_file['SHP SWASH FOLDER'][i] heatmap_crop_poly=params_file['HEATMAP CROP POLY'][i] - final_las = params_file['FINAL LAS'][i] - heatmap_las = params_file['HEATMAP LAS'][i] + final_las = params_file['LAS FINAL FOLDER'][i] + # heatmap_las = params_file['HEATMAP LAS'][i] zone_MGA=params_file['ZONE MGA'][i] output_poly_name=params_file['OUTPUT POLY NAME'][i] path_2_output_poly=params_file['PATH TO OUTPUT'][i] @@ -383,7 +387,19 @@ for i in range(0, len(params_file)): #0, len(params_file) tmp_dir=params_file['TEMP DIR'][i] int_dir=params_file['INTERIM DIR'][i] + # Get base name of input las + las_basename = os.path.splitext(os.path.basename(original_las))[0] + + # Get name of input point cloud + input_las = os.path.join(classified_las_dir, las_basename + '.las') + + # Get name of swash cropping polygon + crop_swash_poly = os.path.join(shp_swash_dir, las_basename + '.shp') + # crop and get the output las + las_data = call_lastools('lasclip', input=input_las, output='-stdout', + args=['-poly', crop_swash_poly], verbose=False) + crop_las(input_las5, crop_swash_poly, final_las, path_2_lastools) #now crop out the heatmap las