从 OSMNX 中的不同地址下载街道
download streets from different address in OSMNX
我想使用列表在 osmnx 中下载不同的街道,但我在我的代码中找不到错误。
我试过这种方法
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
它似乎无法为您的某个查询找到任何内容,可能是因为“阿拉伯联合酋长国科威特”不存在。这是两个不同的国家。
科威特是一个国家而不是一个城市。您可以添加适当的错误处理代码:
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}")
我想使用列表在 osmnx 中下载不同的街道,但我在我的代码中找不到错误。
我试过这种方法
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
它似乎无法为您的某个查询找到任何内容,可能是因为“阿拉伯联合酋长国科威特”不存在。这是两个不同的国家。
科威特是一个国家而不是一个城市。您可以添加适当的错误处理代码:
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}")