iduedu.graph_to_gdf¶
- iduedu.graph_to_gdf(graph, edges=True, nodes=True, restore_edge_geom=False)[source]¶
Convert a NetworkX graph to GeoDataFrames (edges and/or nodes).
Reads CRS from graph.graph[“crs”]. Depending on flags, returns only nodes, only edges, or a concatenation of both. Optionally reconstructs missing edge geometries from node points.
- Parameters:
- Returns:
- Nodes and/or edges as GeoDataFrame(s).
If both edges and nodes are False, returns None.
- Return type:
(gpd.GeoDataFrame | None)
- Raises:
ValueError – If graph.graph[“crs”] is missing.
Notes
Edge GeoDataFrame uses MultiIndex (u, v).
When both are requested, the result is a vertical concat of nodes then edges.