下载OSM网络(带OSMNx)基于标签值并集的过滤
Download OSM network (with OSMNx) filtering based on the union of tag values
我想从 OSM 下载一个网络,其中包含 2 个基于高速公路和自行车道标签的过滤器。
network=ox.core.graph_from_place ( place_name, custom_filter='["highway"~"cycleway"]["bicycle"!~"no”]’
此命令使 2 个过滤器相交。因此,它获取所有具有 highway = cycleway 且 cycleway 标签不同于值“no”的边。
但是,如果我想与过滤器合并 ["cycleway”~"lane”]
我不知道 OSM 的布尔“或”运算符。
我尝试了以下但它不起作用:
network=ox.core.graph_from_place ( place_name, custom_filter='["highway"~"cycleway"]["bicycle"!~"no”] or ["cycleway”~"lane”]’
network=ox.core.graph_from_place ( place_name, custom_filter='["highway"~"cycleway"]["bicycle"!~"no”] | ["cycleway”~"lane”]’
有没有简单的方法来编写自定义过滤器,使标签值并集?还是我应该下载比我需要的更多的内容,然后按照 #151 中的建议删除边缘?
osmnx 使用 Overpass API 下载 OSM 数据。 Overpass API has no or
operator in the way you are trying to use it. There is a simple union statement which just means "download X, then download Y" (see an example at overpass-turbo 表示“highway=cycleway
或 cycleway=lane
”)。我想你必须在 osmnx 中做同样的事情。
这就是我基于基础设施过滤器联合提取网络的方式。
# get graphs of different infrastructure types, then combine
place = 'Berkeley, California, USA'
G1 = ox.graph_from_place(place, custom_filter='["highway"~"cycleway"]')
G2 = ox.graph_from_place(place, custom_filter='["cycleway”~"lane”]')
G = nx.compose(G1, G2)
我想从 OSM 下载一个网络,其中包含 2 个基于高速公路和自行车道标签的过滤器。
network=ox.core.graph_from_place ( place_name, custom_filter='["highway"~"cycleway"]["bicycle"!~"no”]’
此命令使 2 个过滤器相交。因此,它获取所有具有 highway = cycleway 且 cycleway 标签不同于值“no”的边。
但是,如果我想与过滤器合并 ["cycleway”~"lane”]
我不知道 OSM 的布尔“或”运算符。
我尝试了以下但它不起作用:
network=ox.core.graph_from_place ( place_name, custom_filter='["highway"~"cycleway"]["bicycle"!~"no”] or ["cycleway”~"lane”]’
network=ox.core.graph_from_place ( place_name, custom_filter='["highway"~"cycleway"]["bicycle"!~"no”] | ["cycleway”~"lane”]’
有没有简单的方法来编写自定义过滤器,使标签值并集?还是我应该下载比我需要的更多的内容,然后按照 #151 中的建议删除边缘?
osmnx 使用 Overpass API 下载 OSM 数据。 Overpass API has no or
operator in the way you are trying to use it. There is a simple union statement which just means "download X, then download Y" (see an example at overpass-turbo 表示“highway=cycleway
或 cycleway=lane
”)。我想你必须在 osmnx 中做同样的事情。
这就是我基于基础设施过滤器联合提取网络的方式。
# get graphs of different infrastructure types, then combine
place = 'Berkeley, California, USA'
G1 = ox.graph_from_place(place, custom_filter='["highway"~"cycleway"]')
G2 = ox.graph_from_place(place, custom_filter='["cycleway”~"lane”]')
G = nx.compose(G1, G2)