使用 OpenStreetMap 和 OSMNX 检索 post 个 covid 弹出式自行车道

Retrieve post covid pop-up cycleways with OpenStreetMap and OSMNX

意大利的 OSM 社区已开始使用许多政府创建的“紧急”或“弹出式”自行车道来更新 OSM,以保证社交距离,同时 public 减少交通使用。

那些自行车道通常只是粉刷过,所以它们在 OSM 中被标记为这样(街道右侧的示例):

高速公路=二级 自行车道 = 左侧:share_busway,右侧:车道

我想使用 OSMNX 和 custom_filter 检索所有这些自行车道。 我尝试了以下方法:


cf = '["cicleway[left side]"~"share_busway"]'

G = ox.graph_from_bbox(44.493251,44.488272,11.330840,11.301927,custom_filter=cf, simplify=True,truncate_by_edge=False)

但我得到回应:

osmnx.core.EmptyOverpassResponse: There are no data elements in the response JSON objects

我显然不知道如何正确查询,但我不知道该怎么做。

可以用OSMnx查询方式tag/value组合,正如documentation and usage examples. As you can see on OSM中描述的,例如标签是cycleway:right,它的值是lane .

import networkx as nx
import osmnx as ox
ox.config(use_cache=True)
place = 'Bologna, Italia'

# get everything with a 'cycleway' tag
cf = '["cycleway"]'
G = ox.graph_from_place(place, custom_filter=cf)
print(len(G))

# get everything with a 'cycleway:left' tag
cf = '["cycleway:left"]'
G = ox.graph_from_place(place, custom_filter=cf)
print(len(G))

# get everything with a 'cycleway:right' tag
cf = '["cycleway:right"]'
G = ox.graph_from_place(place, custom_filter=cf)
print(len(G))

# get everything with a 'cycleway:right' tag if its value is 'lane'
cf = '["cycleway:right"="lane"]'
G = ox.graph_from_place(place, custom_filter=cf)
print(len(G))

# get everything with a 'cycleway:right' or 'cycleway:left' tag
cf1 = '["cycleway:left"]'
cf2 = '["cycleway:right"]'
G1 = ox.graph_from_place(place, custom_filter=cf1)
G2 = ox.graph_from_place(place, custom_filter=cf2)
G = nx.compose(G1, G2)
print(len(G))

另见 and and