nird package

NIRD - National Infrastructure Resilience Demonstrator

Submodules

nird.constants module

Constants used in the network flow model

nird.road_capacity module

nird.utils module

Utility functions

nird.utils.add_lines(x: DataFrame, from_nodes_df: DataFrame, to_nodes_df: DataFrame, from_nodes_id: str, to_nodes_id: str) → LineString[source]
nird.utils.ckdnearest(gdA: GeoDataFrame, gdB: GeoDataFrame) → GeoDataFrame[source]

Taken from https://gis.stackexchange.com/questions/222315/finding-nearest-point-in-other-geodataframe-using-geopandas

nird.utils.components(edges: DataFrame, nodes: DataFrame, node_id_col: str) → Tuple[DataFrame, DataFrame][source]
nird.utils.create_network_from_nodes_and_edges(nodes: GeoDataFrame | None, edges: GeoDataFrame, node_edge_prefix: str, snap_distance: float | None = None, by: List[str] | None = None) → Network[source]
nird.utils.extract_gdf_values_containing_nodes(x: GeoSeries, input_gdf: GeoDataFrame, column_name: str) → GeoSeries[source]
nird.utils.gdf_geom_clip(gdf_in: GeoDataFrame, clip_geom: Polygon) → GeoDataFrame[source]

Filter a dataframe to contain only features within a clipping geometry

Parameters

gdf_in

geopandas dataframe to be clipped in

province_geom

shapely geometry of province for what we do the calculation

Returns

filtered dataframe

nird.utils.getDistance(loc1: Tuple[float | int, float | int], loc2: Tuple[float | int, float | int]) → float[source]

Haversine formula - give coordinates as (lat_decimal,lon_decimal) tuples

nird.utils.get_flow_on_edges(save_paths_df: DataFrame, edge_id_column: str, edge_path_column: str, flow_column: str) → DataFrame[source]

Get flows from paths onto edges Parameters ——— save_paths_df

Pandas DataFrame of OD flow paths and their flow values

edge_id_column

String name of ID column of edge dataset

edge_path_column

String name of column which contains edge paths

flow_column

String name of column which contains flow values

Result

DataFrame with edge_ids and their total flows

nird.utils.get_nearest_values(x: GeoSeries, input_gdf: GeoDataFrame, column_name: str) → GeoDataFrame[source]
nird.utils.load_config(config_path: str | None = None) → Dict[str, Dict[str, str]][source]

Read config.json

nird.utils.network_od_path_estimations(graph: Graph, source: str | float | int, target: str | float | int, cost_criteria: str) → Tuple[List[List[str | float | int]], List[float]][source]

Estimate the paths, distances, times, and costs for given OD pair

Parameters

graph

igraph network structure

source

name of Origin node ID

target

name of Destination node ID

cost_criteria

name of generalised cost criteria to be used: min_gcost or max_gcost

Returns

edge_path_list

nested lists of edge ID’s in routes

path_gcost_list

estimated generalised costs of routes