Reputation: 483
I try the following code:
G = ox.graph_from_place('Greater London, UK', network_type='walk')
But it keeps giving the following error:
ConnectionError: HTTPSConnectionPool(host='nominatim.openstreetmap.org', port=443): Max retries exceeded with url: /search?format=json&limit=1&dedupe=0&polygon_geojson=1&q=Greater+London%2C+UK (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f50301d5470>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))
Anyone knows anything about this bug? Also is there a way to construct a Graph in osmnx from edges & nodes? From the Following code:
G = ox.gdfs_to_graph(london_nodes, london_edges)
I also keep getting back the following error:
~/miniconda3/lib/python3.6/site-packages/osmnx/save_load.py in gdfs_to_graph(gdf_nodes, gdf_edges)
600 G = nx.MultiDiGraph()
601 G.graph['crs'] = gdf_nodes.crs
--> 602 G.graph['name'] = gdf_nodes.gdf_name.rstrip('_nodes')
603
604 # add the nodes and their attributes to the graph
~/miniconda3/lib/python3.6/site-packages/pandas/core/generic.py in __getattr__(self, name)
4374 if self._info_axis._can_hold_identifiers_and_holds_name(name):
4375 return self[name]
-> 4376 return object.__getattribute__(self, name)
4377
4378 def __setattr__(self, name, value):
AttributeError: 'GeoDataFrame' object has no attribute 'gdf_name'
nodes have been saved before as:
london_nodes = ox.save_load.graph_to_gdfs(G, nodes=True, edges=False)
and edges as:
london_edges = ox.save_load.graph_to_gdfs(G, nodes=False, edges=True)
Thanks in advance.
Upvotes: 2
Views: 1460
Reputation: 6412
Regarding your first question about the ConnectionError, it just looks like the Overpass API was down. It should work if you try again.
Regarding your second question, yes you can convert between MultiDiGraphs and GeoDataFrames:
import osmnx as ox
ox.config(log_console=True, use_cache=True)
G = ox.graph_from_place('Piedmont, CA, USA', network_type='drive')
nodes, edges = ox.graph_to_gdfs(G)
G2 = ox.gdfs_to_graph(nodes, edges)
As you can see from your error message, OSMnx does however expect all of its "expected machinery" to be present for the conversion (including a gdf_name attribute on the GeoDataFrames, for example). You can't convert just any old GeoDataFrames.
Upvotes: 3