Similar to an example in the Overpass by Example library, I'd suggest to use the following query:
[timeout:60];
area["name"="Mayenne"]->.boundaryarea;
way(area.boundaryarea)["building"="church"];
foreach(
node(w)->.n;
.n is_in->.a;
area.a[name][boundary=administrative][admin_level~"^[2-8]$"] -> .a;
out center;
convert way ::=::,
::id = id(),
is_in=a.set("{" + t["admin_level"] + ":" + t["name"] + "}");
out;
);
Step-by-step explanation how this query works:
- It iterates over each
building=church
in your area
- determines all nodes for each building
- find out in which areas those nodes are (this is the actual georeferencing step)
- filter out all areas with
boundary=administrative
and admin_level between 2 and 8 (you can adjust those if needed).
- print out the center point of the church building way
- generates an artificial element with the same way id and an additional element
is_in
, which lists all administrative boundaries the church is in.
- prints out artificial element
Note that the query returns two ways for each church, one with a center node, and one with an is_in
entry but without geometry. At this time, you have to manually merge those two ways. In a later version of Overpass API this will change, though, returning only one single result including geometry.
The line containing georeferencing information looks as follows:
Result is also available here for download: https://gist.github.com/mmd-osm/497252a37d174b187c7afc0238200fc5
amenity=place_of_worship
as well. There are 864226 of them (nodes and ways), whilebuilding=church
only has 200886. For the admin division, you have to look intoadmin_level
. It depends on your study area how deep they are detailed.admin_level
or to perform reverse geocoding.is_in
for that purpose, see below.