I would like to extract several bike touring routes from Open Street Map using the OSMNX package.
For example, this bike route has the property type=route
and route=bicycle
. However since they are Relations and not Ways, I cannot use the functions in the OSMNX Features module:
Is there a different way to extract this data ?
My attempt using the Features module:
import osmnx as ox
ox.__version__ # '1.5.1'
tags = {"route": "bicycle"}
gdfox = ox.features_from_place("Charente-Maritime", tags)
gdfox.shape # (0,0)
Is there a different way to extract this data?
Yes. Per the OSMnx docs, the features
module searches by OSM tags to find matching elements. You're looking for specific relations here, so you should use the geocoder
module to retrieve them. Per the docs, this module allows you to "retrieve place boundaries or any other OpenStreetMap elements by name or ID." Something like:
import osmnx as ox
ox.settings.log_console = True
ox.geocoder.geocode_to_gdf("R8695368", by_osmid=True)
However, there is one caveat: your example relation is missing in Nominatim itself for some reason. This has happened before (related issue), and it may be worth you inquiring directly with Nominatim on Github if it is missing.