src.dynamic_boundary_conditions.river.align_rec_osm

This script handles the task of obtaining data for REC river inflow segments whose boundary points align with the boundary points of OpenStreetMap (OSM) waterways within a specified distance threshold.

Attributes

log

Exceptions

NoRiverDataException

Exception raised when no river data is to be used for the BG-Flood model.

Functions

get_rec_network_data_on_bbox(→ geopandas.GeoDataFrame)

Obtain REC river network data that intersects with the catchment area boundary, along with the corresponding

get_single_intersect_inflows(→ geopandas.GeoDataFrame)

Identifies REC river segments that intersect the catchment boundary once, then retrieves the segments

get_exploded_multi_intersect(→ geopandas.GeoDataFrame)

Identifies REC river segments that intersect the catchment boundary multiple times,

determine_multi_intersect_inflow_index(→ int)

Determines the index that represents the position of the first inflow boundary point along a REC river segment.

categorize_exploded_multi_intersect(→ Dict[int, ...)

Categorizes boundary points of REC river segments that intersect the catchment boundary multiple times into

get_multi_intersect_inflows(→ geopandas.GeoDataFrame)

Identifies REC river segments that intersect the catchment boundary multiple times, then retrieves the segments

get_rec_inflows_on_bbox(→ geopandas.GeoDataFrame)

Obtain REC river segments that are inflows into the specified catchment area, along with their corresponding

get_osm_waterways_on_bbox(→ geopandas.GeoDataFrame)

Retrieve OpenStreetMap (OSM) waterway data that intersects with the catchment boundary,

align_rec_with_osm(→ geopandas.GeoDataFrame)

Aligns the boundary points of REC river inflow segments with the boundary points of OpenStreetMap (OSM) waterways

get_rec_inflows_aligned_to_osm(→ geopandas.GeoDataFrame)

Obtain data for REC river inflow segments whose boundary points align with the boundary points of

Module Contents

src.dynamic_boundary_conditions.river.align_rec_osm.log
exception src.dynamic_boundary_conditions.river.align_rec_osm.NoRiverDataException

Bases: Exception

Exception raised when no river data is to be used for the BG-Flood model.

src.dynamic_boundary_conditions.river.align_rec_osm.get_rec_network_data_on_bbox(engine: sqlalchemy.engine.Engine, catchment_area: geopandas.GeoDataFrame, rec_network_data: geopandas.GeoDataFrame) geopandas.GeoDataFrame

Obtain REC river network data that intersects with the catchment area boundary, along with the corresponding intersection points on the boundary.

Parameters:
  • engine (Engine) – The engine used to connect to the database.

  • catchment_area (gpd.GeoDataFrame) – A GeoDataFrame representing the catchment area.

  • rec_network_data (gpd.GeoDataFrame) – A GeoDataFrame containing the REC river network data.

Returns:

A GeoDataFrame containing REC river network data that intersects with the catchment area boundary, along with the corresponding intersection points on the boundary.

Return type:

gpd.GeoDataFrame

Raises:

NoRiverDataException – If no REC river segment is found crossing the catchment boundary.

src.dynamic_boundary_conditions.river.align_rec_osm.get_single_intersect_inflows(rec_on_bbox: geopandas.GeoDataFrame) geopandas.GeoDataFrame

Identifies REC river segments that intersect the catchment boundary once, then retrieves the segments that are inflows into the catchment area, along with their corresponding inflow boundary points.

Parameters:

rec_on_bbox (gpd.GeoDataFrame) – A GeoDataFrame containing REC river network data that intersects with the catchment area boundary, along with the corresponding intersection points on the boundary.

Returns:

A GeoDataFrame containing the REC river segments that intersect the catchment boundary once and are inflows into the catchment area, along with their corresponding inflow boundary points.

Return type:

gpd.GeoDataFrame

src.dynamic_boundary_conditions.river.align_rec_osm.get_exploded_multi_intersect(rec_on_bbox: geopandas.GeoDataFrame) geopandas.GeoDataFrame

Identifies REC river segments that intersect the catchment boundary multiple times, transforms MultiPoint geometries into individual Point geometries (boundary points), calculates the distance along the river segment for each boundary point, and adds a new column containing boundary points sorted by their distance along the river.

Parameters:

rec_on_bbox (gpd.GeoDataFrame) – A GeoDataFrame containing REC river network data that intersects with the catchment area boundary, along with the corresponding intersection points on the boundary.

Returns:

A GeoDataFrame containing the REC river segments that intersect the catchment boundary multiple times, along with the corresponding intersection points on the boundary, sorted by distance along the river.

Return type:

gpd.GeoDataFrame

src.dynamic_boundary_conditions.river.align_rec_osm.determine_multi_intersect_inflow_index(multi_intersect_row: pandas.Series) int

Determines the index that represents the position of the first inflow boundary point along a REC river segment.

Parameters:

multi_intersect_row (pd.Series) – A REC river segment that intersects the catchment boundary multiple times, along with the corresponding intersection points on the boundary, sorted by distance along the river.

Returns:

An integer that represents the position of the first inflow boundary point along a REC river segment.

Return type:

int

Raises:

ValueError – If the index that represents the position of the first inflow boundary point along a REC river segment cannot be determined.

src.dynamic_boundary_conditions.river.align_rec_osm.categorize_exploded_multi_intersect(multi_intersect: geopandas.GeoDataFrame) Dict[int, Dict[str, List[shapely.geometry.Point]]]

Categorizes boundary points of REC river segments that intersect the catchment boundary multiple times into ‘inflow’ and ‘outflow’ based on their sequential positions along the river segment etc.

Parameters:

multi_intersect (gpd.GeoDataFrame) – A GeoDataFrame containing the REC river segments that intersect the catchment boundary multiple times, along with the corresponding intersection points on the boundary, sorted by distance along the river.

Returns:

A dictionary where the keys represent the ‘objectid’ values of REC river segments, and the values are dictionaries. Each of these dictionaries contains two lists: ‘inflow’ and ‘outflow,’ which respectively represent the boundary points where water flows into and out of the catchment area.

Return type:

Dict[int, Dict[str, List[Point]]]

src.dynamic_boundary_conditions.river.align_rec_osm.get_multi_intersect_inflows(rec_on_bbox: geopandas.GeoDataFrame) geopandas.GeoDataFrame

Identifies REC river segments that intersect the catchment boundary multiple times, then retrieves the segments that are inflows into the catchment area, along with their corresponding inflow boundary points.

Parameters:

rec_on_bbox (gpd.GeoDataFrame) – A GeoDataFrame containing REC river network data that intersects with the catchment area boundary, along with the corresponding intersection points on the boundary.

Returns:

A GeoDataFrame containing the REC river segments that intersect the catchment boundary multiple times and are inflows into the catchment area, along with their corresponding inflow boundary points.

Return type:

gpd.GeoDataFrame

src.dynamic_boundary_conditions.river.align_rec_osm.get_rec_inflows_on_bbox(engine: sqlalchemy.engine.Engine, catchment_area: geopandas.GeoDataFrame, rec_network_data: geopandas.GeoDataFrame) geopandas.GeoDataFrame

Obtain REC river segments that are inflows into the specified catchment area, along with their corresponding inflow boundary points.

Parameters:
  • engine (Engine) – The engine used to connect to the database.

  • catchment_area (gpd.GeoDataFrame) – A GeoDataFrame representing the catchment area.

  • rec_network_data (gpd.GeoDataFrame) – A GeoDataFrame containing the REC river network data.

Returns:

A GeoDataFrame containing REC river segments that are inflows into the catchment area, along with their corresponding inflow boundary points.

Return type:

gpd.GeoDataFrame

Raises:

NoRiverDataException – If no REC river segment is found crossing the catchment boundary.

src.dynamic_boundary_conditions.river.align_rec_osm.get_osm_waterways_on_bbox(engine: sqlalchemy.engine.Engine, catchment_area: geopandas.GeoDataFrame) geopandas.GeoDataFrame

Retrieve OpenStreetMap (OSM) waterway data that intersects with the catchment boundary, along with the corresponding intersection points on the boundary.

Parameters:
  • engine (Engine) – The engine used to connect to the database.

  • catchment_area (gpd.GeoDataFrame) – A GeoDataFrame representing the catchment area.

Returns:

A GeoDataFrame containing OpenStreetMap (OSM) waterway data that intersects with the catchment boundary, along with the corresponding intersection points on the boundary.

Return type:

gpd.GeoDataFrame

src.dynamic_boundary_conditions.river.align_rec_osm.align_rec_with_osm(rec_inflows_on_bbox: geopandas.GeoDataFrame, osm_waterways_on_bbox: geopandas.GeoDataFrame, distance_m: int = 300) geopandas.GeoDataFrame

Aligns the boundary points of REC river inflow segments with the boundary points of OpenStreetMap (OSM) waterways within a specified distance threshold.

Parameters:
  • rec_inflows_on_bbox (gpd.GeoDataFrame) – A GeoDataFrame containing REC river network segments where water flows into the catchment area, along with their corresponding inflow boundary points.

  • osm_waterways_on_bbox (gpd.GeoDataFrame) – A GeoDataFrame containing OpenStreetMap (OSM) waterway data that intersects with the catchment boundary, along with the corresponding intersection points on the boundary.

  • distance_m (int = 300) – Distance threshold in meters for spatial proximity matching. The default value is 300 meters.

Returns:

A GeoDataFrame containing the boundary points of REC river inflow segments aligned with the boundary points of OpenStreetMap (OSM) waterways within a specified distance threshold.

Return type:

gpd.GeoDataFrame

src.dynamic_boundary_conditions.river.align_rec_osm.get_rec_inflows_aligned_to_osm(engine: sqlalchemy.engine.Engine, catchment_area: geopandas.GeoDataFrame, rec_network_data: geopandas.GeoDataFrame, distance_m: int = 300) geopandas.GeoDataFrame

Obtain data for REC river inflow segments whose boundary points align with the boundary points of OpenStreetMap (OSM) waterways within a specified distance threshold.

Parameters:
  • engine (Engine) – The engine used to connect to the database.

  • catchment_area (gpd.GeoDataFrame) – A GeoDataFrame representing the catchment area.

  • rec_network_data (gpd.GeoDataFrame) – A GeoDataFrame containing the REC river network data.

  • distance_m (int = 300) – Distance threshold in meters for spatial proximity matching. The default value is 300 meters.

Returns:

A GeoDataFrame containing data for REC river inflow segments whose boundary points align with the boundary points of OpenStreetMap (OSM) waterways within a specified distance threshold.

Return type:

gpd.GeoDataFrame

Raises:

NoRiverDataException – If no REC river segment is found crossing the catchment boundary.