Closed adamamer20 closed 1 year ago
Not a bug. You saved the graph with:
ox.io.save_graph_geopackage(roads, './roads.gpkg')
but it's a directed graph (which you wanted to reload again later as a directed graph), so you should use:
ox.io.save_graph_geopackage(roads, './roads.gpkg', directed=True)
From the docs:
directed (bool) – if False, save one edge for each undirected edge in the graph but retain original oneway and to/from information as edge attributes; if True, save one edge for each directed edge in the graph
GeoPackages serialize geometrical data, not topological data, so it makes sense to have just one "linestring" for each graph "edge". But the network itself is topological, and as a directed graph, you need one edge from node u to node v and another back from v to u.
Ah thank you! It's my first time working with osmnx and directed graphs.
Contributing guidelines
Documentation
Existing issues
What operating system and Python version are you using?
Windows 10/Conda 23.3.1/Python 3.10.12.final.0
What OSMnx version are you using?
1.6.0
Environment packages and versions
How did you install OSMnx?
Conda and conda-forge
Problem description
I have downloaded a graph using
osmnx.graph.graph_from_place
and saved to a geopackage file usingosmnx.io.save_graph_geopackage
. When loading the geopackage usinggeopandas
,osmnx.distance.shortest_path
cannot find a path (ReturnsNone
). The same issue does not occur when saving and loading from a graphml file (as recommended in the User Reference "To save/load graphs to/from disk for later use in OSMnx, use the io.save_graphml and io.load_graphml functions instead.").Complete minimal reproducible example