diff --git a/src/data/csv_to_geojson.py b/src/data/csv_to_geojson.py index d7481b3..41b5c5a 100644 --- a/src/data/csv_to_geojson.py +++ b/src/data/csv_to_geojson.py @@ -37,10 +37,11 @@ def lat_lon_from_profile_x_coord(center_lat_lon, orientation, center_profile_x, @click.command() @click.option("--sites-csv", required=True, help=".csv file to convert") -@click.option("--profile-csv", required=True, help=".csv file to convert") +@click.option("--profiles-csv", required=True, help=".csv file to convert") +@click.option("--crest-toes-csv", required=True, help=".csv file to convert") @click.option("--impacts-csv", required=True, help=".csv file to convert") @click.option("--output-geojson", required=True, help="where to store .geojson file") -def R_high_to_geojson(sites_csv, profiles_csv, impacts_csv, output_geojson): +def R_high_to_geojson(sites_csv, profiles_csv, crest_toes_csv, impacts_csv, output_geojson): """ Converts impact R_high into a lat/lon geojson that we can plot in QGIS :param sites_csv: @@ -49,13 +50,9 @@ def R_high_to_geojson(sites_csv, profiles_csv, impacts_csv, output_geojson): :param output_geojson: :return: """ - sites_csv = "./data/interim/sites.csv" - profiles_csv = "./data/interim/profiles.csv" - impacts_csv = "./data/interim/impacts_forecasted_mean_slope_sto06.csv" - output_geojson = "./data/interim/R_high_forecasted_mean_slope_sto06.geojson" - df_sites = pd.read_csv(sites_csv, index_col=[0]) df_profiles = pd.read_csv(profiles_csv, index_col=[0, 1, 2]) + df_crest_toes = pd.read_csv(crest_toes_csv, index_col=[0, 1]) df_impacts = pd.read_csv(impacts_csv, index_col=[0]) # Create geojson file @@ -77,9 +74,10 @@ def R_high_to_geojson(sites_csv, profiles_csv, impacts_csv, output_geojson): df_profile = df_profiles.loc[(site_id, "prestorm")] int_x = crossings(df_profile.index.get_level_values("x").tolist(), df_profile.z.tolist(), R_high_z) - # Take most landward interesection. Continue to next site if there is no intersection + # Take the intersection closest to the dune face. try: - int_x = max(int_x) + dune_face_x = np.mean(df_crest_toes.loc[(site_id, 'prestorm'), :].x) + int_x = min(int_x, key=lambda x:abs(x-dune_face_x)) except: continue @@ -100,7 +98,7 @@ def R_high_to_geojson(sites_csv, profiles_csv, impacts_csv, output_geojson): @click.option("--sites-csv", required=True, help=".csv file to convert") @click.option("--profile-features-csv", required=True, help=".csv file to convert") @click.option("--output-geojson", required=True, help="where to store .geojson file") -def profile_features_to_geojson(sites_csv, profile_features_csv, output_geojson): +def profile_features_crest_toes_to_geojson(sites_csv, profile_features_csv, output_geojson): """ Converts profile_features containing dune toes and crest locations to a geojson we can load into QGIS :param sites_csv: