Fix position of R_high in geojson to be closest to dune face

develop
Chris Leaman 6 years ago
parent 3af90601ef
commit 2d22734bfa

@ -37,10 +37,11 @@ def lat_lon_from_profile_x_coord(center_lat_lon, orientation, center_profile_x,
@click.command() @click.command()
@click.option("--sites-csv", required=True, help=".csv file to convert") @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("--impacts-csv", required=True, help=".csv file to convert")
@click.option("--output-geojson", required=True, help="where to store .geojson file") @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 Converts impact R_high into a lat/lon geojson that we can plot in QGIS
:param sites_csv: :param sites_csv:
@ -49,13 +50,9 @@ def R_high_to_geojson(sites_csv, profiles_csv, impacts_csv, output_geojson):
:param output_geojson: :param output_geojson:
:return: :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_sites = pd.read_csv(sites_csv, index_col=[0])
df_profiles = pd.read_csv(profiles_csv, index_col=[0, 1, 2]) 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]) df_impacts = pd.read_csv(impacts_csv, index_col=[0])
# Create geojson file # 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")] 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) 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: 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: except:
continue 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("--sites-csv", required=True, help=".csv file to convert")
@click.option("--profile-features-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") @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 Converts profile_features containing dune toes and crest locations to a geojson we can load into QGIS
:param sites_csv: :param sites_csv:

Loading…
Cancel
Save