我尝试使用custom_filter,它适用于某些小型道路网络,但是对于像整个悉尼网络这样的大型道路网络而言,它却无效。在输出文件中,还有其他一些我不想要的高速公路类型。

custom_filter='["highway"~"motorway|motorway_link|trunk|trunk_link|primary|primary_link|secondary|secondary_link|tertiary|tertiary_link|road|road_link|service|service_link\
                unclassified|unclassified_link"]'
G=ox.core.graph_from_place('Sydney,Australia',network_type='drive', \
                           simplify=True, infrastructure='way["highway"]', custom_filter=custom_filter)

最佳答案

这是一个仅获取高速公路及其链接的简单示例(请注意network_type=None):

import osmnx as ox
ox.config(use_cache=True, log_console=True)
custom_filter = '["highway"~"motorway|motorway_link"]'
G = ox.graph_from_place('Sydney, Australia', network_type=None, simplify=True, infrastructure='way["highway"]', custom_filter=custom_filter)
print(ox.graph_to_gdfs(G, nodes=False)['highway'].value_counts())

关于python - osmnx:如何过滤高速公路类型?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58386781/

10-13 00:06