This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

How to get nodes and ways by polygon in a single Overpass query

0

How can I get all the nodes and ways within some polygon in a single Overpass API query? For example, I can get all the ways like this;out;) and all the nodes like this.

But how might I combine these HTTP GET requests into a single query?

asked 28 Sep '16, 17:03

gboeing's gravatar image

gboeing
1366613
accept rate: 0%


One Answer:

1

Take a look at the union operator:

https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Union

You will have to repeat the poly statement. Here's the poly example from the docs wrapped in a union:

(
  node(poly:"50.7 7.1 50.7 7.2 50.75 7.15");
  way(poly:"50.7 7.1 50.7 7.2 50.75 7.15");
  rel(poly:"50.7 7.1 50.7 7.2 50.75 7.15");
);

answered 28 Sep '16, 22:04

maxerickson's gravatar image

maxerickson
12.7k1083176
accept rate: 32%

Thanks, yes, the wrapping parentheses were what I needed.

(29 Sep '16, 03:18) gboeing

Source code available on GitHub .