正确的 OSMnx 自定义过滤器语法

时间:2021-02-18 17:11:08

标签: openstreetmap osmnx overpass-api

我刚刚更新到更新版本的 OSMnx (0.16),我的一个脚本不再有效。

  G = ox.graph_from_point(yx, 
                    dist = 5000,
                    dist_type = 'bbox', 
                    infrastructure = 'way["railway"]',
                    network_type = 'none',
                    custom_filter = '["service"!~"yard|siding"]["railway"~"%s"],
                    truncate_by_edge = True,
                    retain_all = True
                     )

这旨在拉动所有地铁,但排除所有侧线。但是,infrastructure 参数在最新版本中不再可用。

显然,我需要在自定义查询中合并 infrastructure 信息,但是,我不确定如何执行此操作。我不确定客户过滤器的正确语法应该是什么。

任何想法都会有很大帮助!

1 个答案:

答案 0 :(得分:1)

通读 OSMnx documentation 和用法 examples。他们解释了如何使用自定义过滤器。并通读 Overpass 查询语言 wiki,其中非常详细地解释了语法本身。

import osmnx as ox
point = 40.750972, -73.992778
G = ox.graph_from_point(point,
                        custom_filter = '["railway"~"subway"]["service"!~"yard|siding"]',
                        truncate_by_edge = True,
                        retain_all = True)
len(G) #79
相关问题