transport_frames.indicators

Module for getting area and territory indicators

Functions

calculate_distances(from_gdf, to_gdf, graph)

Compute the minimum distances from each point in the origin GeoDataFrame to the nearest point in the destination GeoDataFrame using the road network graph.

get_bus_routes_num(area_polygons[, ...])

Calculate the number of unique bus routes intersecting each area polygon.

get_connectivity(settlement_points, ...[, ...])

Calculate connectivity scores for each area polygon based on settlement points and a transport network.

get_distance_from(point, settlement_points, ...)

Calculate the median distance from settlement points to a reference point within specified area polygons.

get_distance_to_federal_roads(...)

Compute the median distance from settlements to federal roads for each area polygon.

get_distance_to_region_admin_center(...)

Compute the median distance from settlements to the regional administrative center for each area polygon.

get_railway_length(railway_paths, ...)

Calculate the total railway length within each area polygon.

get_reg_length(graph, area_polygons)

Compute the total length of roads by regional classification within each area polygon.

get_road_density(graph, area_polygons)

Compute road density for each area polygon.

get_road_length(graph, area_polygons)

Calculate the total road length within each area polygon.

get_service_accessibility(settlement_points, ...)

Compute the median accessibility time from settlements to transport services within each area polygon.

get_service_count(area_polygons, service)

Count the number of service points located within each area polygon.

get_terr_distance_to_region_admin_center(...)

Compute the median distance from a territory center to the regional administrative center.

get_terr_nature_distance(territory, ...[, ...])

Compute the number of nature objects within a territory and the distance to the nearest one.

get_terr_nearest_centers(territory, graph[, ...])

Compute distances from a territory to the nearest district and settlement centers.

get_terr_road_density(graph, territory_polygon)

Compute the road density within a given territory.

get_terr_service_accessibility(graph, ...)

Compute service accessibility indicators for a given territory.

get_terr_service_count(territory_polygon, ...)

Count the number of service points within a given territory, considering a 3 km buffer.

Classes

PointSchema(*args, **kwargs)

Schema for validating points.

PolygonSchema(*args, **kwargs)

Schema for validating polygons.

class transport_frames.indicators.PolygonSchema(*args, **kwargs)[source]

Bases: BaseSchema

Schema for validating polygons.

Variables:

_geom_types (list) – List of allowed geometry types for the blocks, default is [shapely.Polygon]

name: Series[str] = 'name'
class Config

Bases: Config

name = 'PolygonSchema'
class transport_frames.indicators.PointSchema(*args, **kwargs)[source]

Bases: BaseSchema

Schema for validating points.

Variables:

_geom_types (list) – List of allowed geometry types for the points, default is [shapely.Point]

class Config

Bases: Config

name = 'PointSchema'
transport_frames.indicators.calculate_distances(from_gdf: GeoDataFrame, to_gdf: GeoDataFrame, graph: MultiDiGraph, weight: str = 'length_meter', unit_div: int = 1000) GeoDataFrame[source]

Compute the minimum distances from each point in the origin GeoDataFrame to the nearest point in the destination GeoDataFrame using the road network graph.

Parameters:
  • from_gdf (gpd.GeoDataFrame) – GeoDataFrame containing origin points.

  • to_gdf (gpd.GeoDataFrame) – GeoDataFrame containing destination points.

  • graph (nx.MultiDiGraph) – Road network graph representing transport connections.

  • weight (str, optional) – Edge attribute used for distance calculation (default is “length_meter”).

  • unit_div (int, optional) – Factor to convert distance into desired units (default is 1000 for km).

Returns:

Series containing the minimum distances in the specified units.

Return type:

gpd.GeoDataFrame

transport_frames.indicators.get_distance_from(point: GeoDataFrame, settlement_points: GeoDataFrame, area_polygons: GeoDataFrame, graph: MultiDiGraph, local_crs: int) GeoDataFrame[source]

Calculate the median distance from settlement points to a reference point within specified area polygons.

Parameters:
  • point (gpd.GeoDataFrame) – GeoDataFrame containing the reference point to measure distances from.

  • settlement_points (gpd.GeoDataFrame) – GeoDataFrame containing settlement points.

  • area_polygons (gpd.GeoDataFrame) – GeoDataFrame representing area polygons.

  • graph (nx.MultiDiGraph) – Transport network graph.

  • local_crs (int) – Coordinate reference system (CRS) to use.

Returns:

GeoDataFrame with median distances to the reference point for each area polygon.

Return type:

gpd.GeoDataFrame

transport_frames.indicators.get_distance_to_region_admin_center(region_admin_center: GeoDataFrame, settlement_points: GeoDataFrame, area_polygons: GeoDataFrame, graph: MultiDiGraph) GeoDataFrame[source]

Compute the median distance from settlements to the regional administrative center for each area polygon.

Parameters:
  • region_admin_center (gpd.GeoDataFrame) – GeoDataFrame containing the regional administrative center point.

  • settlement_points (gpd.GeoDataFrame) – GeoDataFrame containing settlement points.

  • area_polygons (gpd.GeoDataFrame) – GeoDataFrame representing the area polygons.

  • graph (nx.MultiDiGraph) – Transport network graph.

Returns:

Updated area polygons with a new column for median distances to the regional administrative center.

Return type:

gpd.GeoDataFrame

transport_frames.indicators.get_distance_to_federal_roads(settlement_points: GeoDataFrame, area_polygons: GeoDataFrame, graph: MultiDiGraph) GeoDataFrame[source]

Compute the median distance from settlements to federal roads for each area polygon.

Parameters:
  • settlement_points (gpd.GeoDataFrame) – GeoDataFrame containing settlement points.

  • area_polygons (gpd.GeoDataFrame) – GeoDataFrame representing the area polygons.

  • graph (nx.MultiDiGraph) – Transport network graph.

Returns:

Updated area polygons with a new column for median distances to federal roads.

Return type:

gpd.GeoDataFrame

transport_frames.indicators.get_connectivity(settlement_points: GeoDataFrame, area_polygons: GeoDataFrame, local_crs: int, graph: MultiDiGraph | None = None, adj_mx: DataFrame | None = None) GeoDataFrame[source]

Calculate connectivity scores for each area polygon based on settlement points and a transport network.

Parameters:
  • settlement_points (gpd.GeoDataFrame) – GeoDataFrame containing settlement points.

  • area_polygons (gpd.GeoDataFrame) – GeoDataFrame representing area polygons.

  • local_crs (int) – Coordinate reference system (CRS) to use.

  • graph (nx.MultiDiGraph, optional) – Transport network graph (required if adjacency matrix is not provided).

  • adj_mx (pd.DataFrame, optional) – Precomputed adjacency matrix.

Returns:

Area polygons with computed connectivity values.

Return type:

gpd.GeoDataFrame

transport_frames.indicators.get_road_length(graph: MultiDiGraph, area_polygons: GeoDataFrame) GeoDataFrame[source]

Calculate the total road length within each area polygon.

Parameters:
  • graph (nx.MultiDiGraph) – Transport network graph.

  • area_polygons (gpd.GeoDataFrame) – GeoDataFrame representing area polygons.

Returns:

Area polygons with an additional column indicating the total road length (in kilometers).

Return type:

gpd.GeoDataFrame

transport_frames.indicators.get_road_density(graph: MultiDiGraph, area_polygons: GeoDataFrame) GeoDataFrame[source]

Compute road density for each area polygon.

Parameters:
  • graph (nx.MultiDiGraph) – Transport network graph.

  • area_polygons (gpd.GeoDataFrame) – GeoDataFrame representing area polygons.

Returns:

Area polygons with calculated road density (road length per unit area).

Return type:

gpd.GeoDataFrame

transport_frames.indicators.get_reg_length(graph: MultiDiGraph, area_polygons: GeoDataFrame) GeoDataFrame[source]

Compute the total length of roads by regional classification within each area polygon.

Parameters:
  • graph (nx.MultiDiGraph) – The transport network graph.

  • area_polygons (gpd.GeoDataFrame) – The polygons representing the areas of interest.

Returns:

Updated area polygons with additional columns for road length by regional classification.

Return type:

gpd.GeoDataFrame

transport_frames.indicators.get_service_count(area_polygons: GeoDataFrame, service: GeoDataFrame) GeoDataFrame[source]

Count the number of service points located within each area polygon.

Parameters:
  • area_polygons (gpd.GeoDataFrame) – The polygons representing areas of interest.

  • service (gpd.GeoDataFrame) – The GeoDataFrame containing service points.

Returns:

Area polygons with an added column for the number of services.

Return type:

gpd.GeoDataFrame

transport_frames.indicators.get_service_accessibility(settlement_points: GeoDataFrame, graph: MultiDiGraph, area_polygons: GeoDataFrame, service: GeoDataFrame) GeoDataFrame[source]

Compute the median accessibility time from settlements to transport services within each area polygon.

Parameters:
  • settlement_points (gpd.GeoDataFrame) – GeoDataFrame containing settlement points.

  • graph (nx.MultiDiGraph) – The transport network graph.

  • area_polygons (gpd.GeoDataFrame) – The polygons representing areas of interest.

  • service (gpd.GeoDataFrame) – GeoDataFrame of transport service points.

Returns:

Area polygons with computed median accessibility times for each service.

Return type:

gpd.GeoDataFrame

transport_frames.indicators.get_bus_routes_num(area_polygons: GeoDataFrame, bus_edges: GeoDataFrame | None = None, public_transport_graph: MultiDiGraph | None = None, polygon_gdf: GeoDataFrame | None = None) GeoDataFrame[source]

Calculate the number of unique bus routes intersecting each area polygon.

Parameters:
  • area_polygons (gpd.GeoDataFrame) – The polygons representing areas of interest.

  • bus_edges (gpd.GeoDataFrame, optional) – GeoDataFrame containing bus network edges with route attributes.

  • public_transport_graph (nx.MultiDiGraph, optional) – The public transport graph.

  • polygon_gdf (gpd.GeoDataFrame, optional) – A polygon GeoDataFrame used to extract the public transport graph.

Returns:

Area polygons with an additional column indicating the number of unique bus routes.

Return type:

gpd.GeoDataFrame

transport_frames.indicators.get_railway_length(railway_paths: GeoDataFrame, area_polygons: GeoDataFrame, local_crs: int) GeoDataFrame[source]

Calculate the total railway length within each area polygon.

Parameters:
  • railway_paths (gpd.GeoDataFrame) – GeoDataFrame containing railway path geometries.

  • area_polygons (gpd.GeoDataFrame) – The polygons representing areas of interest.

  • local_crs (int) – The coordinate reference system to use.

Returns:

Area polygons with an added column indicating the railway length (in kilometers).

Return type:

gpd.GeoDataFrame

transport_frames.indicators.get_terr_service_accessibility(graph: MultiDiGraph, territory_polygon: GeoDataFrame, service: GeoDataFrame) GeoDataFrame[source]

Compute service accessibility indicators for a given territory.

Parameters:
  • graph (nx.MultiDiGraph) – The transport network graph.

  • territory_polygon (gpd.GeoDataFrame) – Polygon representing the territory of interest.

  • service (gpd.GeoDataFrame) – GeoDataFrame containing service points.

Returns:

Updated territory polygons with: - ‘number_of_service’: Count of services inside. - ‘service_accessibility’: Travel time to the nearest service.

Return type:

gpd.GeoDataFrame

transport_frames.indicators.get_terr_service_count(territory_polygon: GeoDataFrame, service: GeoDataFrame, local_crs: int = 3856) GeoDataFrame[source]

Count the number of service points within a given territory, considering a 3 km buffer.

Parameters:
  • territory_polygon (gpd.GeoDataFrame) – The polygon(s) representing areas of interest.

  • service (gpd.GeoDataFrame) – GeoDataFrame containing service points.

  • local_crs (int, optional) – The coordinate reference system (default is 3856).

Returns:

Territory polygons with an added column indicating the number of services.

Return type:

gpd.GeoDataFrame

transport_frames.indicators.get_terr_road_density(graph: MultiDiGraph, territory_polygon: GeoDataFrame) GeoDataFrame[source]

Compute the road density within a given territory.

Parameters:
  • graph (nx.MultiDiGraph) – The transport network graph.

  • territory_polygon (gpd.GeoDataFrame) – The polygon(s) representing the territory.

Returns:

Territory polygons with an added column for road density.

Return type:

gpd.GeoDataFrame

transport_frames.indicators.get_terr_distance_to_region_admin_center(region_admin_center: GeoDataFrame, territory_polygon: GeoDataFrame, graph: MultiDiGraph) GeoDataFrame[source]

Compute the median distance from a territory center to the regional administrative center.

Parameters:
  • region_admin_center (gpd.GeoDataFrame) – The regional administrative center point.

  • territory_polygon (gpd.GeoDataFrame) – The polygons representing the territory.

  • graph (nx.MultiDiGraph) – The transport network graph.

Returns:

Updated territory polygons with a new column for the median distance to the regional admin center.

Return type:

gpd.GeoDataFrame

transport_frames.indicators.get_terr_nature_distance(territory: GeoDataFrame, nature_objects: GeoDataFrame, local_crs: int = 3857) GeoDataFrame[source]

Compute the number of nature objects within a territory and the distance to the nearest one.

Parameters:
  • territory (gpd.GeoDataFrame) – The area polygons where nature accessibility is calculated.

  • nature_objects (gpd.GeoDataFrame) – GeoDataFrame containing nature objects (e.g., parks, reserves).

  • local_crs (int, optional) – The coordinate reference system (default is 3857).

Returns:

Updated territory with: - ‘number_of_objects’: Count of nature objects within. - ‘objects_accessibility’: Distance to the nearest nature object.

Return type:

gpd.GeoDataFrame

transport_frames.indicators.get_terr_nearest_centers(territory: GeoDataFrame, graph: MultiDiGraph, districts: GeoDataFrame | None = None, centers_points: GeoDataFrame | None = None, local_crs: int = 3857) GeoDataFrame[source]

Compute distances from a territory to the nearest district and settlement centers.

Parameters:
  • territory (gpd.GeoDataFrame) – The polygons representing the territory.

  • graph (nx.MultiDiGraph) – The transport network graph.

  • districts (gpd.GeoDataFrame, optional) – GeoDataFrame of district boundaries.

  • centers_points (gpd.GeoDataFrame, optional) – GeoDataFrame containing district/settlement centers.

  • local_crs (int, optional) – The coordinate reference system (default is 3857).

Returns:

Updated territory polygons with: - ‘to_nearest_district_center_km’: Distance to the nearest district center.

Return type:

gpd.GeoDataFrame