Search code examples
openstreetmapoverpass-api

OSM Overpass: Query within relation


If I want to query for certain objects within an area, it's quite easy:

area(...);
node(area)[natural=peak];
out;

But what if the area is defined as a relation in the OSM database? I could query for the area like this ...

(rel(...);>;);
out;

... but how can I use the area filter on it then?


Solution

  • You can either apply the same filter criteria to area, as you would for your relation - or - use map_to_area to calculate the corresponding area for a relation:

    rel(...);map_to_area;
    node(area)[natural=peak];
    out;
    

    Check out the documentation for more details.