【问题标题】:osmnx: how can I filter the the highway type?osmnx:如何过滤高速公路类型?
【发布时间】:2020-06-07 07:11:13
【问题描述】:

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

【问题讨论】:

  • 欢迎来到 Stackoverflow!请尝试发布Minimal, Complete Example 来证明您遇到的问题。为了让我们更好地帮助您,请尝试包含完整的代码脚本、输入/输出数据的描述或示例以及您遇到的任何错误。通过说 - “它不起作用” - 我们不知道这意味着什么。请描述如何它不起作用。
  • 您能否分享一下您在输出中获得的哪些高速公路类型是您不想要的?

标签: python osmnx


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2019-02-13
    • 1970-01-01
    • 2021-12-25
    • 1970-01-01
    • 2019-09-12
    • 1970-01-01
    • 2020-03-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多