【问题标题】:OSMnx: Creating Custom Queries with Alternative InfrastructuresOSMnx:使用替代基础架构创建自定义查询
【发布时间】:2020-07-19 15:46:51
【问题描述】:

我通常是 OSMnx 和 Overpass 查询的新手。我试图了解在使用非街道基础设施类型时编写自定义查询的正确方法。

具体来说,我想了解为什么这个查询有效

import osmnx as ox

my_custom_filter = '["railway"~"disused"]' 

G = ox.graph_from_point((51.5073509,-0.1277583), 
                      distance = 10000,
                      distance_type = 'bbox', 
                      infrastructure = 'way["railway]',
                      network_type = 'none',
                      custom_filter = my_custom_filter
                       )

但是这个使用了一个错误的请求错误:

import osmnx as ox

my_custom_filter = '["railway"~"disused"]' 

G = ox.graph_from_point((51.5073509,-0.1277583), 
                      distance = 10000,
                      distance_type = 'bbox', 
                      infrastructure = 'way["railway~"rail"]',
                      network_type = 'none',
                      custom_filter = my_custom_filter
                       )

注意区别只是我在后面的查询中指定 rail 作为铁路的类型。

在此处查看OSM Railway Guide

如果有人可以向我指出任何可以帮助我进一步了解如何构建自定义过滤器的资源 - 特别是具有多个过滤器的自定义过滤器,那也很好。例如,添加额外客户过滤器的正确语法是什么。

【问题讨论】:

    标签: openstreetmap overpass-api osmnx


    【解决方案1】:

    你只是在你的论点中遗漏了"。这有效:

    import osmnx as ox
    ox.config(log_console=True, use_cache=True)
    point = (51.5073509,-0.1277583)
    dist = 10000
    dt = 'bbox'
    cf = '["railway"~"disused"]' 
    G = ox.graph_from_point(point, dist=dist, dist_type=dt, custom_filter=cf)
    

    但它会产生EmptyOverpassResponse 错误,因为在该搜索区域中没有与您的查询匹配的内容。但是,如果您将其更改为此,您将获得一个图表,例如:

    cf = '["railway"!~"disused"]' 
    G = ox.graph_from_point(point, dist=dist, dist_type=dt, custom_filter=cf)
    

    【讨论】:

      猜你喜欢
      • 2019-03-27
      • 1970-01-01
      • 2022-01-05
      • 2014-12-02
      • 2022-01-05
      • 2015-10-17
      • 1970-01-01
      • 2022-01-04
      • 1970-01-01
      相关资源
      最近更新 更多