osmnx:如何过滤高速公路类型?

时间:2019-10-15 03:22:48

标签: python osmnx

我尝试过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)

1 个答案:

答案 0 :(得分:2)

这是一个仅获取高速公路及其链接的简单示例(请注意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())