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

标签 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)

最佳答案

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

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

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

相关文章:

python - 正则表达式查找第一次出现的字符,除非它在某个字符集中

python - 如何在 Python 中使用 OSMnx 填充水体

openstreetmap - 使用 OSMNX : how to retrieve the Hannover subway network? 打开街道 map

python osmnx - 只提取一个国家的大型高速公路

python - 转换 osmnx 投影 map 的经纬度坐标

python - 仅反转列表中的整数,无需切片或反向()

python - Django-models - 通过 FK 描述在 Django 管理中显示对象

python - 第一次安装virtualenvwrapper,无法运行初始化钩子(Hook)

python - Python 中的每类常量

OSMnx : how to provide more complex feature into the custom_filter parameter