transport_frames.graph
Module for creating city network graph from polygon
Functions
|
Assigns reg_status to nodes based on edge data. |
|
Downloads the drive graph from OSM. |
|
Collects a drive graph from polygon. |
Classes
|
Schema for validating polygons. |
- class transport_frames.graph.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]
- transport_frames.graph.get_graph_from_polygon(polygon: GeoDataFrame, local_crs: int) MultiDiGraph [source]
Collects a drive graph from polygon.
- Parameters:
polygon (gpd.GeoDataFrame) – GeoDataFrame of territory boundary polygon
local_crs (int) – Local projection CRS
- Returns:
City network drive graph.
- Return type:
nx.MultiDiGraph
- transport_frames.graph.from_polygon_iduedu(polygon: GeoDataFrame, local_crs: int, buffer=3000) MultiDiGraph [source]
Downloads the drive graph from OSM.
- Parameters:
polygon (gpd.GeoDataFrame) – GeoDataFrame of the Polygon
local_crs (int) – Local projection CRS
buffer (int) – The size of buffer for edges cropping
- Returns:
City network drive graph
- Return type:
nx.MultiDiGraph
- transport_frames.graph.classify_nodes(graph: MultiDiGraph) MultiDiGraph [source]
Assigns reg_status to nodes based on edge data.
- Parameters:
graph (nx.MultiDiGraph) – The road network graph with classified edges
- Returns:
City network drive graph with classified nodes and edges
- Return type:
nx.MultiDiGraph
- transport_frames.graph._crop_edges_by_polygon(graph: MultiDiGraph, polygon: Polygon) MultiDiGraph [source]
Updates edge geometries based on intersections with the city boundary.
- Parameters:
graph (nx.MultiDiGraph) – The city network graph
polygon (Polygon) – The Polygon to crop edges with
- Returns:
City network drive graph with cropped edges
- Return type:
nx.MultiDiGraph
- transport_frames.graph._create_graph(edges: GeoDataFrame, nodes_coord: dict) MultiDiGraph [source]
Create a graph based on edges and node coordinates.
- Parameters:
edges (gpd.GeoDataFrame:) – The edges with their attributes and geometries
nodes_coord (dict) – A dictionary containing node coordinates
- Returns:
The constructed graph
- Return type:
nx.MultiDiGraph