【问题标题】:How to import multiple infrastructure type in osmnx?如何在 osmnx 中导入多种基础设施类型?
【发布时间】:2020-09-04 22:41:07
【问题描述】:

在使用 osmnx 导入道路时,有没有办法为基础设施类型指定多个子类别。从this question 我了解到我们只能通过指定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 (examples here , keys here)

【问题讨论】:

    标签: osmnx


    【解决方案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
    

    另见https://stackoverflow.com/a/62883614/7321942

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-26
      • 2016-04-26
      • 1970-01-01
      • 2023-03-20
      • 1970-01-01
      • 2011-06-19
      • 2013-03-07
      • 1970-01-01
      相关资源
      最近更新 更多