How to import multiple infrastructure type in osmnx?

混江龙づ霸主 提交于 2020-06-01 05:54:46

问题


Is there any way to specify multiple subcategories for an infrastructure type while importing roads using osmnx. From this question I understand that we can select only freeways by specifying infrastructure='way["highway"~"motorway"]'. How can we expand this to include multiple categories such as highways = motorway or primary or secondary or highway is not footway

I tried the following without success:

infrastructure='way["highway"~"motorway"],way["highway"~"primary"]'
infrastructure='way["highway"~"motorway", "primary"]'
infrastructure='way["highway"~"motorway" OR "primary"]'

It would be nice to have better filtering such as highway=primary or highway=primary_link (examples here , keys here)


回答1:


Use the pipe | as an overpass or operator like:

import osmnx as ox
ox.config(use_cache=True, log_console=True)
place = 'Berkeley, California, USA'

infra = 'way["highway"~"motorway"]'
G = ox.graph_from_place(place, network_type='drive', infrastructure=infra)
print(len(G)) #36

infra = 'way["highway"~"primary"]'
G = ox.graph_from_place(place, network_type='drive', infrastructure=infra)
print(len(G)) #11

infra = 'way["highway"~"motorway|primary"]'
G = ox.graph_from_place(place, network_type='drive', infrastructure=infra)
print(len(G)) #47


来源:https://stackoverflow.com/questions/61881345/how-to-import-multiple-infrastructure-type-in-osmnx

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!