Search code examples
openstreetmapoverpass-api

How to extract all nodes and ways from relationship with at least one tag?


I am using overpass to create some queries.

My goal is to search within a box, all the relationships of type multipolygon. From those I want to extract all the possible way and node items which have at least one tag.

So far I was able to display all the the multipolygons like so:

[bbox: 48.18329,16.3765,48.18466,16.37787];
rel["type" = "multipolygon"] -> .relation;
way(r.relation);
(._;>>;);
/*end of auto repair*/
out body;

However I totally have no clue how to extract all the nodes and items with at least one tag. Same thing for the nodes.

Do you know a smart and elegant solution to achieve this task?


Solution

  • I was able to achieve my goal the following way:

    [bbox: 48.18329,16.3765,48.18466,16.37787];
    rel["type" = "multipolygon"] -> .relation;
    (
      way(r.relation)(if:count_tags() > 0); 
    );
    (._;>>;);
    /*end of auto repair*/
    out body;
    

    In addition if you want to filter out some other ways just use the following code:

    [bbox: 48.18329,16.3765,48.18466,16.37787];
    rel["type" = "multipolygon"] -> .relation;
    (
      way(r.relation)(if:count_tags() > 0); - 
      (
      way(r.relation)[~"highway|aeroway|barrier|railway|tunnel"~"."];
      );
    );
    (._;>>;);
    /*end of auto repair*/
    out body;
    

    Hope it helps somebody else as well.