src.dynamic_boundary_conditions.river.river_network_for_aoi
This script processes REC data to construct a river network for the defined catchment area.
Attributes
Functions
|
Generates a dictionary that contains the unique node coordinates in the REC data for the catchment area. |
|
Add columns for the first and last coordinates/nodes of each LineString in the REC data within the catchment area. |
|
Calculate and add an 'intersection_type' column to the GeoDataFrame that contains REC data with node information. |
Prepares the necessary data for constructing the river network for the catchment area using the REC data. |
|
|
Add nodes to the REC river network along with their attributes. |
|
Add initial edges to the REC river network along with their attributes. |
|
Identify edges that are absent from the REC river network and require addition. |
|
Add absent edges that are required for the current river network construction to the REC river network along with |
Add edge directions to the river network data based on the provided REC river network. |
|
Remove REC river network edges that are not connected to their respective sea-draining catchment's end nodes. |
|
|
Builds a river network for the catchment area using the REC data. |
|
Retrieve or create REC river network for the specified catchment area. |
Module Contents
- src.dynamic_boundary_conditions.river.river_network_for_aoi.log
- src.dynamic_boundary_conditions.river.river_network_for_aoi.get_unique_nodes_dict(rec_data_w_node_coords: geopandas.GeoDataFrame) Dict[shapely.geometry.Point, int]
Generates a dictionary that contains the unique node coordinates in the REC data for the catchment area.
- Parameters:
rec_data_w_node_coords (gpd.GeoDataFrame) – A GeoDataFrame containing the REC data for the catchment area with additional columns for the first and last coordinates of each LineString.
- Returns:
A dictionary that contains the unique node coordinates (Point objects) in the REC data for the catchment area.
- Return type:
Dict[Point, int]
- src.dynamic_boundary_conditions.river.river_network_for_aoi.add_nodes_to_rec(rec_data_with_sdc: geopandas.GeoDataFrame) geopandas.GeoDataFrame
Add columns for the first and last coordinates/nodes of each LineString in the REC data within the catchment area.
- Parameters:
rec_data_with_sdc (gpd.GeoDataFrame) – A GeoDataFrame containing the REC data for the catchment area with an additional column that identifies the associated sea-draining catchment for each REC geometry.
- Returns:
A GeoDataFrame containing the REC data for the catchment area with additional columns for the first and last coordinates/nodes of each LineString.
- Return type:
gpd.GeoDataFrame
- src.dynamic_boundary_conditions.river.river_network_for_aoi.add_nodes_intersection_type(catchment_area: geopandas.GeoDataFrame, rec_data_with_nodes: geopandas.GeoDataFrame) geopandas.GeoDataFrame
Calculate and add an ‘intersection_type’ column to the GeoDataFrame that contains REC data with node information.
- Parameters:
catchment_area (gpd.GeoDataFrame) – A GeoDataFrame representing the catchment area.
rec_data_with_nodes (gpd.GeoDataFrame) – A GeoDataFrame containing the REC data for the catchment area with additional columns for the first and last coordinates/nodes of each LineString.
- Returns:
The input GeoDataFrame with the ‘intersection_type’ column added.
- Return type:
gpd.GeoDataFrame
- src.dynamic_boundary_conditions.river.river_network_for_aoi.prepare_network_data_for_construction(catchment_area: geopandas.GeoDataFrame, rec_data_with_sdc: geopandas.GeoDataFrame) geopandas.GeoDataFrame
Prepares the necessary data for constructing the river network for the catchment area using the REC data.
- Parameters:
catchment_area (gpd.GeoDataFrame) – A GeoDataFrame representing the catchment area.
rec_data_with_sdc (gpd.GeoDataFrame) – A GeoDataFrame containing the REC data for the catchment area with an additional column that identifies the associated sea-draining catchment for each REC geometry.
- Returns:
A GeoDataFrame containing the necessary data for constructing the river network for the catchment area.
- Return type:
gpd.GeoDataFrame
- src.dynamic_boundary_conditions.river.river_network_for_aoi.add_nodes_to_network(rec_network: networkx.Graph, prepared_network_data: geopandas.GeoDataFrame) None
Add nodes to the REC river network along with their attributes.
- Parameters:
rec_network (nx.Graph) – The REC river network, a directed graph, to which nodes will be added.
prepared_network_data (gpd.GeoDataFrame) – A GeoDataFrame containing the necessary data for constructing the river network for the catchment area.
- Returns:
This function does not return any value.
- Return type:
None
- src.dynamic_boundary_conditions.river.river_network_for_aoi.add_initial_edges_to_network(rec_network: networkx.Graph, prepared_network_data: geopandas.GeoDataFrame) None
Add initial edges to the REC river network along with their attributes.
- Parameters:
rec_network (nx.Graph) – The REC river network, a directed graph, to which initial edges will be added.
prepared_network_data (gpd.GeoDataFrame) – A GeoDataFrame containing the necessary data for constructing the river network for the catchment area.
- Returns:
This function does not return any value.
- Return type:
None
- src.dynamic_boundary_conditions.river.river_network_for_aoi.identify_absent_edges_to_add(rec_network: networkx.Graph, prepared_network_data: geopandas.GeoDataFrame) geopandas.GeoDataFrame
Identify edges that are absent from the REC river network and require addition.
- Parameters:
rec_network (nx.Graph) – The REC river network, a directed graph.
prepared_network_data (gpd.GeoDataFrame) – A GeoDataFrame containing the necessary data for constructing the river network for the catchment area.
- Returns:
A GeoDataFrame containing edges that are absent from the REC river network and require addition.
- Return type:
gpd.GeoDataFrame
- src.dynamic_boundary_conditions.river.river_network_for_aoi.add_absent_edges_to_network(engine: sqlalchemy.engine.Engine, catchment_area: geopandas.GeoDataFrame, rec_network: networkx.Graph, prepared_network_data: geopandas.GeoDataFrame) None
Add absent edges that are required for the current river network construction to the REC river network along with their attributes.
- Parameters:
engine (Engine) – The engine used to connect to the database.
catchment_area (gpd.GeoDataFrame,) – A GeoDataFrame representing the catchment area.
rec_network (nx.Graph) – The REC river network, a directed graph, to which absent edges will be added.
prepared_network_data (gpd.GeoDataFrame) – A GeoDataFrame containing the necessary data for constructing the river network for the catchment area.
- Returns:
This function does not return any value.
- Return type:
None
- src.dynamic_boundary_conditions.river.river_network_for_aoi.add_edge_directions_to_network_data(engine: sqlalchemy.engine.Engine, rec_network_id: int, rec_network: networkx.Graph, prepared_network_data: geopandas.GeoDataFrame) geopandas.GeoDataFrame
Add edge directions to the river network data based on the provided REC river network. Subsequently, eliminate REC geometries from the network data where the edge direction is absent (None), and append these excluded REC geometries to the relevant database table.
- Parameters:
engine (Engine) – The engine used to connect to the database.
rec_network_id (int) – An identifier for the river network associated with the current run.
rec_network (nx.Graph) – The REC river network, a directed graph, used to determine the edge directions.
prepared_network_data (gpd.GeoDataFrame) – A GeoDataFrame containing the necessary data for constructing the river network for the catchment area.
- Returns:
A GeoDataFrame containing the updated river network data with added edge directions.
- Return type:
gpd.GeoDataFrame
- src.dynamic_boundary_conditions.river.river_network_for_aoi.remove_unconnected_edges_from_network(engine: sqlalchemy.engine.Engine, rec_network_id: int, rec_network: networkx.Graph, rec_network_data: geopandas.GeoDataFrame) geopandas.GeoDataFrame
Remove REC river network edges that are not connected to their respective sea-draining catchment’s end nodes.
- Parameters:
engine (Engine) – The engine used to connect to the database.
rec_network_id (int) – An identifier for the river network associated with the current run.
rec_network (nx.Graph) – The REC river network, a directed graph, used to identify edges that are connected to the end nodes of their respective sea-draining catchments.
rec_network_data (gpd.GeoDataFrame) – A GeoDataFrame containing the REC river network data with added edge directions.
- Returns:
A GeoDataFrame containing the modified river network data with REC geometries removed if they are not connected to their end nodes within their respective sea-draining catchments.
- Return type:
gpd.GeoDataFrame
- src.dynamic_boundary_conditions.river.river_network_for_aoi.build_rec_river_network(engine: sqlalchemy.engine.Engine, catchment_area: geopandas.GeoDataFrame, rec_network_id: int) Tuple[networkx.DiGraph, geopandas.GeoDataFrame]
Builds a river network for the catchment area using the REC data.
- Parameters:
engine (Engine) – The engine used to connect to the database.
catchment_area (gpd.GeoDataFrame) – A GeoDataFrame representing the catchment area.
rec_network_id (int) – An identifier for the river network associated with the current run.
- Returns:
A tuple containing the constructed REC river network, represented as a directed graph (DiGraph), along with its associated data in the form of a GeoDataFrame.
- Return type:
Tuple[nx.DiGraph, gpd.GeoDataFrame]
- src.dynamic_boundary_conditions.river.river_network_for_aoi.get_rec_river_network(engine: sqlalchemy.engine.Engine, catchment_area: geopandas.GeoDataFrame) Tuple[networkx.Graph, geopandas.GeoDataFrame]
Retrieve or create REC river network for the specified catchment area.
- Parameters:
engine (Engine) – The engine used to connect to the database.
catchment_area (gpd.GeoDataFrame) – A GeoDataFrame representing the catchment area.
- Returns:
A tuple containing the REC river network as a directed graph (DiGraph) and its associated data as a GeoDataFrame.
- Return type:
Tuple[nx.Graph, gpd.GeoDataFrame]