Feraman
Feraman

Reputation: 39

OSMNX not able to import graphs or GDF from a place

I am trying to import the graphs and GDFs of few locations for my analysis:

import osmnx as ox
import geopandas as gpd
import networkx as nx
print(ox.__version__)
ox.config(use_cache=True, log_console=True)
Kinshasa = [ "Kisenso, Mont Amba, 31, Democratic Republic of the Congo",
"N'djili, Tshangu, Democratic Republic of the Congo",
"Kinshasa, Democratic Republic of the Congo"]
cf = '["highway"~"residential|tertiary"]' 

GDF_Kinshasa = ox.geocode_to_gdf(Kinshasa)
G_Kinshasa = ox.graph.graph_from_place(Kinshasa, simplify=True, network_type='drive')

All packages were imported just fine. However, after running the code, I got the following error:

G_Kinshasa = ox.graph.graph_from_place(Kinshasa, simplify=True, network_type='drive')
2021-01-04 23:02:02 Retrieved response from cache file "cache/90bf90f753deea13c94e5d85a594adef.json"
Traceback (most recent call last):

File "<ipython-input-20-ed05e2c7d4b0>", line 1, in <module>
G_Kinshasa = ox.graph.graph_from_place(Kinshasa, simplify=True, network_type='drive')

File "/Users/microman/opt/anaconda3/envs/Kinshasa/lib/python3.7/site-packages/osmnx/graph.py", line 334, in graph_from_place
gdf_place = geocoder.geocode_to_gdf(query, buffer_dist=buffer_dist)

File "/Users/microman/opt/anaconda3/envs/Kinshasa/lib/python3.7/site-packages/osmnx/geocoder.py", line 97, in geocode_to_gdf
gdf = gdf.append(_geocode_query_to_gdf(q, wr))

File "/Users/microman/opt/anaconda3/envs/Kinshasa/lib/python3.7/site-packages/osmnx/geocoder.py", line 142, in _geocode_query_to_gdf
raise ValueError(f'OSM returned no results for query "{query}"')

ValueError: OSM returned no results for query "Kisenso, Mont Amba, 31, Democratic Republic of the Congo"

I am using OSMNX version 0.16.2 and MAC OS with python 3.7. The code was running fine last time I tried under OSMNX version 0.15.1. I think the issue is with Open Street Maps API but cannot confirm it.

Would be grateful if anyone can suggest what is going on.

Upvotes: 0

Views: 577

Answers (1)

gboeing
gboeing

Reputation: 6442

The error message says:

ValueError: OSM returned no results for query "Kisenso, Mont Amba, 31, Democratic Republic of the Congo"

You can try that query for yourself and see that OpenStreetMap has no matching results.

As stated in the docs, you must provide OSMnx a geocodable place name to use the graph_from_place function, but you currently are not. You'll need to change your query such that it can be resolved. Perhaps it was resolvable in the past, but the OpenStreetMap data must have changed and it no longer is. Also note that OSMnx v1.0.0 is the latest release.

Upvotes: 1

Related Questions