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

Get enclosing borders

0

Can I use Overpass-API to get all administrative entities enclosing (partially or completely) an object. i.e. I have a wood like Sarghai (https://www.openstreetmap.org/way/475130161) and I want to know that it lies at least partially within a national park (Nationalpark Harz) and Harz (LK Goslar) administrative boundaries and lower saxony. Best case would be a Overpass-API script where I can give a Node, Way or Relation and receive all enclosing administrative entities.

asked 08 Apr '20, 10:37

Ogmios's gravatar image

Ogmios
766202639
accept rate: 25%

1

Have a read up of 'is_in'

(08 Apr '20, 12:04) DaveF

Thanks DaveF, that was helpful. I just have to figure out how to use a node/way/rel instead of a coordinate but so far it works well:

[out:csv(::id, name)][timeout:25]; ( is_in(51.70785, 10.45692)->.a; / * boundary=national_park = Nationalpark * boundary=protected_area = Naturschutzgebiet * boundary=administrative = Landrkeise, Länder etc. / area.a ["boundary"~"national_park|protected_area"] ->.b;

area.a ["boundary"="administrative"] ["admin_level"!="2"] ->.c;

rel(pivot.b)->.b; rel(pivot.c)->.c; ); .b out geom; .c out geom;

(08 Apr '20, 17:47) Ogmios

One Answer:

1
// All boundaries enclosing an entity (forest)
way(475130161);
out geom;
(._;>;);
is_in;
rel(pivot)[boundary];
out geom;

https://overpass-turbo.eu/s/SAZ

answered 08 Apr '20, 18:05

DaveF's gravatar image

DaveF
3.3k8498133
accept rate: 16%

edited 08 Apr '20, 18:23

Great, thanks.

(08 Apr '20, 20:01) Ogmios

Source code available on GitHub .