File tree Expand file tree Collapse file tree 1 file changed +5
-11
lines changed
Expand file tree Collapse file tree 1 file changed +5
-11
lines changed Original file line number Diff line number Diff line change 1- """
2- @file cartography.py
3- @brief Cartography utilities for retrieving and processing OpenStreetMap data.
4-
5- This module provides functions to download and process street network data
6- from OpenStreetMap using OSMnx, with support for graph simplification and
7- standardization of attributes.
8- """
9-
101import networkx as nx
112import osmnx as ox
123
@@ -129,6 +120,10 @@ def get_cartography(
129120 else :
130121 G [u ][v ][k ][key ] = value
131122
123+ # Add id to edges
124+ for i , (u , v , k ) in enumerate (G .edges (keys = True )):
125+ G [u ][v ][k ]["id" ] = i
126+
132127 # Standardize node attributes in the graph
133128 nodes_to_update = []
134129 for node , data in G .nodes (data = True ):
@@ -188,9 +183,8 @@ def get_cartography(
188183 # Convert back to MultiDiGraph temporarily for ox.graph_to_gdfs compatibility
189184 gdf_nodes , gdf_edges = ox .graph_to_gdfs (G )
190185
191- # Reset index and add edge id
186+ # Reset index and rename columns (id already exists from graph)
192187 gdf_edges .reset_index (inplace = True )
193- gdf_edges ["id" ] = gdf_edges .index
194188 gdf_edges .rename (columns = {"u" : "source" , "v" : "target" }, inplace = True )
195189 gdf_edges .drop (columns = ["key" ], inplace = True , errors = "ignore" )
196190
You can’t perform that action at this time.
0 commit comments