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

Overpass: Match not only borders, but also inside area

0

I'm trying to retrieve the forests within a specific (relatively small) bounding box with Overpass API. I'm using the following query:

[out:json][timeout:25];
(
  way["landuse"="forest"]({{bbox}});
  relation["landuse"="forest"]({{bbox}});
);
out body;
>;
out skel qt;

When the edge of the forest intersects my bounding box, the query works as intended:

alt text

But once the bounding box is completely inside of the forest, I receive no results:

alt text

Is there any way to fix this?

asked 27 Nov '18, 09:15

misotrnka's gravatar image

misotrnka
16112
accept rate: 0%


One Answer:

1

It's not a 100% answer, but for forests with names, you can retrieve them using is_in:

is_in(48.21634,17.12552) ->.in;
(
 way(pivot.in)[landuse=forest];
 rel(pivot.in)[landuse=forest];
);
out geom;

the is_in operator returns Overpass-API areas, the pivot statements retrieve the underlying geometries related to those features. You can look in https://github.com/drolbr/Overpass-API/blob/master/src/rules/areas.osm3s to see the rules for the features that will be returned by is_in.

answered 27 Nov '18, 14:48

maxerickson's gravatar image

maxerickson
12.7k1083176
accept rate: 32%

Thank you, this actually works perfectly. I just need to make a query with a bounding box and another query for the center point.

(28 Nov '18, 07:38) misotrnka

Source code available on GitHub .