Search code examples
openstreetmapoverpass-api

Writing a query for getting all nodes within multiple Bounding Boxes


nwr(51.477,-0.001,51.478,0.001);
out;

This is the most standard query, but I am trying to have multiple of these bboxes within one query. I have no idea how to achieve this and not sure whether it is possible.


Solution

  • You can do a union of two queries as described in the Overpass wiki:

    (
     nwr(51.477,-0.001,51.478,0.001);
     nwr(51.477,0.001,51.478,0.002);
    );
    out;
    

    Or you could try to combine them in a polygon, and do a query with a polygon. You just have to be a bit careful on how they overlap. You have to use 5 points per box, to make sure that it closes (last point is the same as the first), so you don't get areas between your boxes. So it might not be easier than the union above.

    nwr(poly:"latitude_1 longitude_1 latitude_2 longitude_2 latitude_3 longitude_3 …"));
    

    for example:

    node(poly:"51.477 -0.001 51.477 0.01 51.48 0.01 51.48 -0.001 51.477 -0.001 51.470 -0.01 51.470 0.001 51.472 0.001 51.472 -0.01 51.470 -0.01");
    out geom;