In OSM, some buildings stand on administrative borders; for example, the base of the building https://www.openstreetmap.org/way/333896751 intersects the neighboring municipalities Riedering, Rohrdorf and Stephanskirchen, even though these seem to share no common area.
In Overpass, area-based filtering apparently allows restricting result sets to features where some part of the geometry is in contact with an area, which likely explains that certain queries yield a nonempty intersection of "straddling" buildings, even when the underlying areas appear "geometrically disjunctive".
For instance:
// buildings in Riedering:
[out:json]; wr[building](area:3602186935); out geom;
// buildings in Stephanskirchen:
[out:json]; wr[building](area:3602186942); out geom;
// some buildings appear to belong to both administrative areas:
[out:json]; wr[building](area:3602186935)(area:3602186942); out geom;
For a certain statistical analysis that should be stratified by municipalities, I would like to modify the above queries so that each building should belong unambiguously to a single municipality. Since building centers have no expansion, I assume that these should mostly be unequivocal w.r.t. identifying a single underlying municipality. For example, according to its center, the mentioned building would be interpreted as belonging to Rohrdorf:
[out:json]; // computed via [out:json]; way(333896751); out center;
is_in(47.8373143, 12.1714380);
wr(pivot)[admin_level=8][boundary=administrative];
out geom;
This suggests that unequivocal building sets could be computed from sequences of Overpass queries that (initially) calculate building centers and that (in a second step) identify underlying municipalities. When reading about features such as the more recent center()-function, I was wondering whether such a maneuver could be integrated into a single query, which for a given municipality (e.g., Stephanskirchen) yields a set of unambiguous buildings (i.e. whose centers lie on the area). Unfortunately, I could not come up with an executable syntax. Do you have any idea?