Friday 14 April 2017

qgis - An Overpass query for OSM ways; both part of a relation and also a specific tag?


How do I construct an Overpass query to find data on Openstreetmap which is both part of a relation and has itself a specific attribute?


Specifically: I'm wanting to find sections of cycle route (in a route relation) AND which are surfaced a particular way using Overpass - accessed using the Quick OSM plugin on QGIS.


So in terms of the OSM data I'm looking for a relation with type=route and route=bicycle http://wiki.openstreetmap.org/wiki/Cycle_routes#Relations


But I want to limit this by surface - lets say surface=paved or surface=asphalt http://wiki.openstreetmap.org/wiki/Key:surface


Ideally I'd like to do this using the QGIS Quick OSM plugin - but if necessary I'm happy to use the Overpass Turbo website.


I'm well out of my depth on getting the syntax correct for this (although I've used all these systems for simpler queries).



Answer




I was really wondering how to do this, so I asked the question at help.openstreetmap.org as @scai suggested, and Roland Olbricht (developer of Overpass API) was kind enough to supply the query pasted below. Read the full answer for an explanation.


[out:json][timeout:90];
rel["route"="bicycle"]({{bbox}});
way(r);
way._["surface"="paved"];
out geom;

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...