ripple1d.conflate package#

Submodules#

ripple1d.conflate.rasfim module#

Conflation classes and functions.

class ripple1d.conflate.rasfim.RasFimConflater(nwm_pq, source_model_directory, ras_model_name, output_concave_hull_path=None, min_flow_multiplier=0.9, max_flow_multiplier=1.2)#

Bases: object

Conflate NWM and RAS data for a single river reach.

Parameters:
  • nwm_pq (str) – Path to the NWM Parquet file converted to parquet from: s3://noaa-nws-owp-fim/rasfim/inputs/X-National_Datasets/nwm_flows.gpkg

  • source_model_directory (str) – Path to the Source HEC-RAS model directory.

  • ras_model_name (str) – Name of the HEC-RAS model.

  • load_data (bool, optional) – Load the data on initialization. Defaults to True.

Raises:
  • ValueError – Required layer not found in the GeoPackage:

  • DriverError – Unable to read the GeoPackage:

add_hull(xs_gdf, reach)#

Add the concave hull to the GeoDataFrame.

check_centerline()#

Ensure that ras_centerline is available and that the centerline is specified.

Helper function.

If the centerline is not specified, the first centerline is used, with a check that there is only one centerline.

property common_crs#

Return the common CRS for the NWM and RAS data.

determine_station_order(xs_gdf, reach)#

Detemine the order based on stationing of the cross sections along the reach.

get_nwm_reach_metadata(reach_id)#

Make a dictionary with relevant NWM information.

Return type:

dict

get_projected_bbox(gdf)#

Return the bounding box for the GeoDataFrame in the common CRS.

Return type:

Polygon

load_data()#

Load the NWM and RAS data from the GeoPackages.

load_gpkg(gpkg)#

Load the RAS data from the GeoPackage.

load_pq(nwm_pq)#

Load the NWM data from the Parquet file.

property local_gages: dict#

Local gages for the NWM reaches.

local_lakes()#

Local lakes for the NWM reaches.

local_nwm_reaches(river_reach_name=None, buffer=0)#

NWM reaches that intersect the RAS cross sections.

Return type:

GeoDataFrame

populate_r_station(row, assume_ft=True)#

Populate the r value for a cross section. The r value is the ratio of the station to actual cross section length.

Return type:

str

property primary_flow_file#

The primary flow file for the HEC-RAS Model.

property primary_geom_file#

The primary geometry file for the HEC-RAS Model.

property primary_plan_file#

The primary plan file for the HEC-RAS Model.

property ras_banks#

Return the banks of the RAS cross sections.

ras_centerline_by_river_reach_name(river_reach_name)#

Return the centerline for the specified river reach.

Return type:

LineString

property ras_centerlines: GeoDataFrame#

RAS centerlines.

property ras_junctions: GeoDataFrame#

RAS junctions.

property ras_metadata: Polygon#

RAS metadata.

property ras_project_file#

The source HEC-RAS project file.

property ras_river_reach_names: List[str]#

Return the unique river reach names in the RAS data.

ras_start_end_points(*args, **kwargs)#
property ras_structures: GeoDataFrame#

RAS structures.

property ras_xs: GeoDataFrame#

RAS cross sections.

property ras_xs_bbox: Polygon#

Return the bounding box for the RAS cross sections.

ras_xs_concave_hull(river_reach_name=None)#

Return the concave hull of the cross sections.

Return type:

Polygon

ras_xs_convex_hull(river_reach_name=None)#

Return the convex hull of the cross sections.

set_ras_gpkg(ras_gpkg, load_data=True)#

Set the RAS GeoPackage and optionally load the data.

property stac_api#

The stac_api for the HEC-RAS Model.

property stac_collection_id#

The stac_collection_id for the HEC-RAS Model.

property stac_item_id#

The stac_item_id for the HEC-RAS Model.

property units#

Units of the source HEC-RAS model.

write_hulls()#

Write the hulls to a GeoPackage.

xs_by_river_reach_name(river_reach_name)#

Return the cross sections for the specified river reach.

Return type:

GeoDataFrame

ripple1d.conflate.rasfim.cacl_avg_nearest_points(reference_gdf, compare_points_gdf)#

Calculate the average distance between the reference points and the nearest points in the comparison GeoDataFrame.

Return type:

float

ripple1d.conflate.rasfim.calculate_reach_coverage(xs, reach)#

Aggregate intersected sections by reach, calculate coverage, and remove backwards reaches.

Return type:

DataFrame

ripple1d.conflate.rasfim.check_for_us_xs(river_reach_rs, xs_gdf)#

Check for another cross section upstream of the most upstream intersected cross section.

Retrieve the river_reach_rs id for the cross section upstream of the most upstream intersected cross section. If there are no cross sections upstream of the most upstream intersecting cross section, then return the most upstream intersecting cross section.

Return type:

str

ripple1d.conflate.rasfim.convert_linestring_to_points(linestring, crs, point_spacing=5)#

Convert a LineString to a GeoDataFrame of Points.

Return type:

GeoDataFrame

ripple1d.conflate.rasfim.count_intersecting_lines(ras_xs, nwm_reaches)#

Return the number of intersecting lines between the RAS cross sections and the NWM reaches.

Return type:

int

ripple1d.conflate.rasfim.endpoints_from_multiline(mline)#

Return the start and end points of a MultiLineString.

Return type:

Tuple[Point, Point]

ripple1d.conflate.rasfim.ensure_geometry_column(gdf)#

Confirm that there exists a geometry column in the GeoDataFrame.

Return type:

GeoDataFrame

ripple1d.conflate.rasfim.get_us_most_xs_from_junction(rfc, us_river, us_reach)#

Search for river reaches at junctions and return xs closest ds reach at junciton.

ripple1d.conflate.rasfim.map_reach_xs(rfc, reach)#

Map the upstream and downstream cross sections for the nwm reach.

TODO: This function needs helper functions to extract the datasets from the GeoDataFrames.

Return type:

dict

ripple1d.conflate.rasfim.nearest_line_to_point(lines, point, column_id='ID', search_radius=1000000000.0, number_of_returns=0)#

Return the ID of the line(s) closest to the point.

The number of lines to return is specified with the ‘number_of_returns’ arg. The ‘search_radius’ is a max distance that a line can be away from the point to be returned.

Return type:

array

ripple1d.conflate.rasfim.ras_reaches_metadata(rfc, candidate_reaches)#

Return the metadata for the RAS reaches.

ripple1d.conflate.rasfim.ras_xs_geometry_data(rfc, xs_id)#

Return the geometry data (max/min xs elevation) for the specified cross section.

Return type:

dict

ripple1d.conflate.rasfim.retrieve_us_ds_xs(rfc, intersected_xs, reach)#

Check that us and ds are hydrologically connected. Select reach with most overlap if not.

Return type:

(str, str)

ripple1d.conflate.rasfim.validate_reach_conflation(reach_xs_data, reach_id)#

Raise error for invalid conflation.

The trim_reach method in subset_gpkg.py will return an empty geodataframe when u/s xs_id is lower than d/s xs_id. This likely indicates poor CRS inference.

ripple1d.conflate.rasfim.walk_network(gdf, start_id, stop_id, river_reach_name)#

Walk the network from the start ID to the stop ID.

Return type:

List[int]

Module contents#

Initialize conflate.