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

get surrounding buildings to a set of nodes with specific tags

1

Dear all,

I want to query overpass-turbo.eu for all buildings that contain at least one node with the tag "country=EU" and "office=government".

I tried so far:

node({{bbox}})[country=EU][office=government];
is_in;
(way[building](pivot);>;);out;

Test on overpass: http://overpass-turbo.eu/s/MaJ (courtesy of mmd)

However, this does not work as areas are not always updated (see discussion with mmd and on github). The results are not complete and not reliable.

Then, I tested to achieve this with the around operator.

[out:json][timeout:25];
// fetch area “Brussels” to search in
{{geocodeArea:Brussels}}->.searchArea;
// gather results
node[office=government][country=EU](area.searchArea)->.offices;
( 
  way[building=yes](around.offices:8);
);
// print results
out body;
(._;>;);
out skel qt;

Test on overpass: http://overpass-turbo.eu/s/Mbp

However, here I do not know how to choose the distance of the around operator. The results are either incomplete or I get false positives, i.e. also neighbouring buildings.

Is there a solution to get the surrounding building of a set of nodes with specific tags?

asked 09 Sep '19, 18:48

rriemann's gravatar image

rriemann
26113
accept rate: 0%

Is it maybe possible to have a foreach loop over all government office and use their geographical location to get all elements on that point (it's possible with the openstreetmap.org context menu query) and then filter out one building?

(10 Sep '19, 09:17) rriemann
1
(20 Sep '19, 22:49) rriemann
1

Is there maybe a work around in a different language? With some python/javascript lib?

(07 Oct '19, 21:19) rriemann

Has a nice code example that can be useful: https://pypi.org/project/osmxtract/

(09 Nov '19, 22:22) rriemann

One Answer:

0

This is my best take so far:

[out:json][timeout:25];
{{geocodeArea:Brussels}}->.searchArea;
// get EU governmental offices nodes
node[office=government][country=EU](area.searchArea)->.offices;
(
        // get all enclosures from EU governmental offices
        .offices is_in->.enclosing;
        // limit result to buildings
        way(pivot.enclosing)[building=yes]->.officebuildings;
);

.officebuildings out geom;
.offices out meta;

Run in overpass turbo: http://overpass-turbo.eu/s/NID

The problem is yet that some buildings are not marked (most of them?).

answered 04 Nov '19, 18:53

rriemann's gravatar image

rriemann
26113
accept rate: 0%