i would like to download different streets in osmnx, using a list but i can't find the error in my code.
i tried this way
name_list = ['Kuwait, United Arab Emirates','Guangzhou, China'] i=0 for file_path in name_list: print(i) CD = file_path filtro_vialidades = '["highway"~"trunk|motorwat|primary|secondary|tertiary|residential"]' GCD=ox.graph_from_address(CD, network_type= "drive", custom_filter= filtro_vialidades) ox.save_graphml(GCD, f"{name_list[i]}.graphml", gephi= False) i =1 #I had this error EmptyOverpassResponse: There are no data elements in the response JSON
CodePudding user response:
It looks like it cannot find anything for one of your queries, probably because "Kuwait, United Arab Emirates" does not exist. These are two separate countries.
CodePudding user response:
Kuwait is a country not a city. You can add appropriate error handling code:
import osmnx as ox
from osmnx._errors import EmptyOverpassResponse
name_list = ['Kuwait, United Arab Emirates','Guangzhou, China']
for i, file_path in enumerate(name_list):
print(i)
CD = file_path
filtro_vialidades = '["highway"~"trunk|motorwat|primary|secondary|tertiary|residential"]'
try:
GCD=ox.graph_from_address(CD, network_type= "drive",
custom_filter= filtro_vialidades)
ox.save_graphml(GCD, f"{name_list[i]}.graphml", gephi= False)
except EmptyOverpassResponse:
print(f"no results: {file_path}")