Add new function 'update_survey_output'

etta-drone
Dan Howe 7 years ago
parent a034361569
commit 4e80a3d86e

@ -96,7 +96,7 @@ def make_raster(las, output, lastools_loc, keep_only_ground=False, step=0.2):
return None
def extract_pts(las_in, cp_in, survey_date, keep_only_ground=True):
def extract_pts(las_in, cp_in, survey_date, beach, keep_only_ground=True):
"""Extract elevations from a las surface based on x and y coordinates.
Requires lastools in system path.
@ -105,6 +105,7 @@ def extract_pts(las_in, cp_in, survey_date, keep_only_ground=True):
las_in: input point cloud (las)
cp_in: point coordinates with columns: id, x, y, z (csv)
survey_date: survey date string, e.g. '19700101'
beach: beach name
keep_only_ground: only keep points classified as 'ground' (boolean)
Returns:
@ -149,7 +150,32 @@ def extract_pts(las_in, cp_in, survey_date, keep_only_ground=True):
return df
def update_survey_output(df, output_dir):
"""Update survey profile output csv files with current survey.
Args:
df: dataframe containing current survey elevations
output_dir: directory where csv files are saved
Returns:
None
"""
# Merge current survey with existing data
profiles = df['Profile'].unique()
for profile in profiles:
csv_name = os.path.join(output_dir, profile + '.csv')
try:
# Load existing results
master = pd.read_csv(csv_name)
except FileNotFoundError:
master = df.copy()
# Add (or update) current survey
current_survey_col = df.columns[-1]
master[current_survey_col] = df[current_survey_col]
# Export updated results
master.to_csv(csv_name)
def plot_profiles(profile_info, profile, output_loc, LL_limit):
@ -365,9 +391,8 @@ for i in range(0, len(params_file)): #0, len(params_file)
make_raster(heatmap_las, output_raster, path_2_lastools, keep_only_ground=True)
#extract the points and get volumes
df = extract_pts(final_las, input_csv, survey_date, keep_only_ground=True)
update_survey_output(df, output_csv_dir)
process_tmp_csv(tmp_csv, survey_date, csv_loc, beach)
df = extract_pts(final_las, input_csv, survey_date, beach, keep_only_ground=True)
update_survey_output(df, csv_loc)
#colourise the point cloud

Loading…
Cancel
Save