The following happens when I use python's osmnx
as follows:
graph = osmnx.graph_from_polygon(Data.bbox)
gdf_nodes, gdf_edges = osmnx.save_load.graph_to_gdfs(
graph,
nodes=True, edges=True,
node_geometry=True,
fill_edge_geometry=True)
print(gdf_edges['u']) # prints the values nicely
graph2 = osmnx.save_load.gdfs_to_graph(gdf_nodes, gdf_edges) # misses 'v' and 'u' column in gdf_nodes
Then I get the following error:
File "C:\Users\jpelda\AppData\Local\Continuum\anaconda3\lib\site-packages\osmnx\save_load.py", line 513, in gdfs_to_graph
G.add_edge(u=row['u'], v=row['v'], key=row['key'], **attrs)
TypeError: add_edge() missing 2 required positional arguments: 'u_for_edge' and 'v_for_edge'
Make sure you're using the latest released versions of OSMnx (0.8.1 as of today) and NetworkX (2.1 as of today). Your code snippet works fine. Complete working example:
import networkx as nx
import osmnx as ox
print(ox.__version__)
print(nx.__version__)
graph = ox.graph_from_place('Piedmont, California, USA', network_type='drive')
gdf_nodes, gdf_edges = ox.graph_to_gdfs(
graph,
nodes=True, edges=True,
node_geometry=True,
fill_edge_geometry=True)
graph2 = ox.gdfs_to_graph(gdf_nodes, gdf_edges)
After 0.13.0 (2020-05-25)
ox.gdfs_to_graph()
has been replaced with ox.graph_from_gdfs()
If your OSMnx's version is after 0.13.0, please using the code below:
graph2 = ox.graph_from_gdfs(gdf_nodes, gdf_edges)