Separate surveys into profiles

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

@ -11,6 +11,7 @@
#export pngs of the surveys #export pngs of the surveys
########################### IMPORTS ########################################### ########################### IMPORTS ###########################################
import os import os
import io
import subprocess import subprocess
import pandas as pd import pandas as pd
import numpy as np import numpy as np
@ -163,16 +164,19 @@ def update_survey_output(df, output_dir):
# Merge current survey with existing data # Merge current survey with existing data
profiles = df['Profile'].unique() profiles = df['Profile'].unique()
for profile in profiles: for profile in profiles:
csv_name = os.path.join(output_dir, profile + '.csv') csv_name = os.path.join(output_csv_dir, profile + '.csv')
# Extract survey data for current profile
current_profile = df[df['Profile'] == profile]
try: try:
# Load existing results # Load existing results
master = pd.read_csv(csv_name) master = pd.read_csv(csv_name)
except FileNotFoundError: except FileNotFoundError:
master = df.copy() master = current_profile.copy()
# Add (or update) current survey # Add (or update) current survey
current_survey_col = df.columns[-1] current_survey_col = df.columns[-1]
master[current_survey_col] = df[current_survey_col] master[current_survey_col] = current_profile[current_survey_col]
# Export updated results # Export updated results
master.to_csv(csv_name) master.to_csv(csv_name)

@ -79,15 +79,18 @@ def update_survey_output(df, output_dir):
profiles = df['Profile'].unique() profiles = df['Profile'].unique()
for profile in profiles: for profile in profiles:
csv_name = os.path.join(output_csv_dir, profile + '.csv') csv_name = os.path.join(output_csv_dir, profile + '.csv')
# Extract survey data for current profile
current_profile = df[df['Profile'] == profile]
try: try:
# Load existing results # Load existing results
master = pd.read_csv(csv_name) master = pd.read_csv(csv_name)
except FileNotFoundError: except FileNotFoundError:
master = df.copy() master = current_profile.copy()
# Add (or update) current survey # Add (or update) current survey
current_survey_col = df.columns[-1] current_survey_col = df.columns[-1]
master[current_survey_col] = df[current_survey_col] master[current_survey_col] = current_profile[current_survey_col]
# Export updated results # Export updated results
master.to_csv(csv_name) master.to_csv(csv_name)
@ -95,3 +98,10 @@ def update_survey_output(df, output_dir):
df = extract_pts(las_in, cp_in, survey_date, keep_only_ground=True) df = extract_pts(las_in, cp_in, survey_date, keep_only_ground=True)
update_survey_output(df, output_csv_dir) update_survey_output(df, output_csv_dir)
master.shape
current_profile.shape
df.shape

Loading…
Cancel
Save