I want to extract all features (nwr) from a given city. I want the ways (w) and all members of multipolygons (r) that intersect the city boundary to be included in the dataset, but not the members of other relations outside the city boundaries.
The following query is a good start, but I can’t figure out how to exclude the members of other relations (except multipolygons) outside the city boundaries. For instance, I get all members of a route relation that goes up to 800 km away from the city!
{{geocodeArea:Sherbrooke}}->.searchArea;
nwr(area.searchArea);
(._;>;); out meta;
Based on @DwarfNebula’s answer, I built a three-part query.
/* Step 1 - request all the features within the city limit (city) */
{{geocodeArea:Sherbrooke}} ->.searchArea;
nw(area.searchArea);
( ._; ._<;) ->.city;
/* Step 2 - expend only the relations of interest found in Step 1 (outside_polygons) */
relation.city[type=“multipolygon”][water!=“river”];
(._; ._>;) ->.outside_polygons;
/* Step 3 - Merge both results with an union statement */
(.city; .outside_polygons;) ->.result;
.result out meta;
I also did it with ways, but didn’t find the result relevant for me, that’s why it doesn’t appear in above query.