Retrieve post covid pop-up cycleways with OpenStreetMap and OSMNX

别来无恙 提交于 2020-08-10 19:07:27

问题


The OSM community in Italy has started to update OSM with "emergency" or "pop-up" cycleways that many administration are creating to guarantee social distancing while public transport use is reduced.

Those cycleways are often just painted, so they are tagged in OSM like this (example for right side of the street):

highway = secondary bike lanes = left side: share_busway , right side: lane

I would like to retrieve all these cycleways using OSMNX and custom_filter. I have tried the following:


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)

but I get in response:

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

I am clearly missing on how to query correctly but I don't know how to do it.


回答1:


You can query with OSMnx for way tag/value combos, just as described in the documentation and usage examples. As you can see on OSM, for example, the tag is cycleway:right and its value is 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))

see also https://stackoverflow.com/a/61897000/7321942



来源:https://stackoverflow.com/questions/62835420/retrieve-post-covid-pop-up-cycleways-with-openstreetmap-and-osmnx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!