-1

I am using OSMnx to download and simplify a road network. But the problem I have is that once I simplify, I cannot preserve the precise geometry/geospatial information of links. The following figure shows the road network drawn from the road network in graph format Road Network from graph

But the interesting fact is if I convert the same network to geodataframe, then that geodataframe has the exact linestring of links like the following figure, Road network from gdf

I want to save the downloaded and simplified road network in .osm format with preserved geometry/geospatial information of links.

I tried to save the road network in .osm format with the pristine geospatial information of links. But the simplified network in a .osm/graphml format does not have that. But the saved network in .gpkg format has the pristine linestring.

Nasir
  • 1
  • Do you have any code? – Wraith Dec 07 '22 at 12:24
  • Here is the code. The gdf from the graph has the original geometry, but the simplified graph has modified geometry. import osmnx as ox import geopandas as gpd import networkx as nx import contextily as ctx import matplotlib.pyplot as plt G=ox.graph.graph_from_bbox(35.9729,35.9604,-83.9149,-83.9404,network_type='drive',simplify=True) G=ox.project_graph(G, to_crs='epsg:3857') nodes, edges = ox.graph_to_gdfs(G, fill_edge_geometry=True) – Nasir Dec 07 '22 at 15:05

1 Answers1

0

I tried to save the road network in .osm format with the pristine geospatial information of links. But the simplified network in a .osm/graphml format does not have that. But the saved network in .gpkg format has the pristine linestring.

That's not true: an OSMnx graph saved in the GraphML format does indeed preserve the edges' geometries, as does GeoPackage format. The .osm XML format does not with a simplified graph, because it cannot. If you need a .osm file at the end, then pass simplify=False when you create your graph.

gboeing
  • 5,691
  • 2
  • 15
  • 41