1

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?

1 Answer 1

0

First of all, I'm starting with an example how to use the center() function to generate the center point for all ways in the current inputset, here for a single way 333896751.

way[building](333896751);
out geom;
convert way :: = ::,
            ::geom = center(geom()),
            ::id = id();
out geom ;
derived._(area:3602186942);   // << area filter on derived object not supported
out geom;

The "convert" statement processes all objects in your inputset and generates so called "derived objects". Derived objects are runtime-only objects that can take over some of the characteristics of the original objects, such as their object id, tags, or geometry.

Now regarding the filtering of those derived objects: unfortunately, the area filter only supports nodes, ways and relations, but not derived objects. This way, you cannot filter your derived objects by municipality areas.

2
  • Thanks for these explanations, I understand that I might need a sequence of queries for the described purpose...
    – Dennis
    Aug 28, 2021 at 13:11
  • Depending on what exactly you're trying to do, you might be better served with a Postgis database. As I have explained before, your requirements are clearly outside of what is supported by Overpass API.
    – mmd
    Aug 28, 2021 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.