iduedu.reproject_graph

iduedu.reproject_graph(graph, target_crs)[source]

Reproject node coordinates (x, y) and edge geometries to a new CRS (in place).

Builds GeoDataFrames for nodes and for edges that have shapely geometry, applies GeoDataFrame.to_crs(target_crs), writes transformed coordinates/geometries back to the graph, and updates graph.graph[“crs”] to the resulting target CRS.

Parameters:
  • graph (networkx.Graph) – Graph with current CRS in graph[“crs”]; nodes carry x, y in that CRS, edges may carry shapely geometry in the same CRS.

  • target_crs – Target CRS accepted by GeoPandas (EPSG int, string like “EPSG:3857”, or a pyproj.CRS).

Returns:

The same graph instance (mutated in place) with updated coordinates/geometries and CRS.

Return type:

(nx.Graph)

Raises:

ValueError – If graph.graph[“crs”] is missing.

Notes

  • Only nodes with both x and y are updated.

  • Edges without shapely geometry are left unchanged.

  • If an edge geometry is stored as a WKT string, it is not reprojected; parse it first.