如何在 osmnx 中导入多种基础设施类型?

How to import multiple infrastructure type in osmnx?

在使用 osmnx 导入道路时,是否有任何方法可以为基础设施类型指定多个子类别。从 我了解到我们可以 select 通过指定 infrastructure='way["highway"~"motorway"]' 只有高速公路。我们如何扩展它以包括多个类别,例如 highways = motorway or primary or secondaryhighway is not footway

我尝试了以下但没有成功:

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

如果有更好的过滤就好了,比如highway=primary or highway=primary_link (examples here , keys here)

使用管道 | 作为立交桥 or 运算符,例如:

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

cf = '["highway"~"motorway|motorway_link"]'
G = ox.graph_from_place(place, network_type='drive', custom_filter=cf)
print(len(G)) #36

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

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

另见