1

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.

Ferrix
  • 59
  • 1
  • 9
  • I don't really understand how you're constructing your query here. Can you provide the OSM IDs of a few of the elements you're hoping to retrieve? – gboeing Jul 11 '20 at 04:28
  • @gboeing for example ways with OSMid: 156231178, 454925332. In this particular case I know the street name, so I was able to query by name cf = '["name"~"Via Saragozza"]' but of course is not a general method, and I also get some cul-de-sac or lateral streets with same name, but no bike lane – Ferrix Jul 12 '20 at 13:42

1 Answers1

3

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 and https://stackoverflow.com/a/62239377/7321942 and https://stackoverflow.com/a/62720802/7321942

gboeing
  • 5,691
  • 2
  • 15
  • 41