小编典典

如何在osmnx中导入多种基础架构类型?

python

在使用osmnx导入道路时,有什么方法可以为基础结构类型指定多个子类别。从这个问题中我了解到,通过指定,我们只能选择高速公路infrastructure='way["highway"~"motorway"]'。我们如何扩展它以包括多个类别,例如highways = motorway or primary or secondary或highway 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


阅读 368

收藏
2020-12-20

共1个答案

小编典典

将管道|用作立交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
2020-12-20