2

I am trying to select and export to GeoJSON all buildings that are located in certain area (city district). The Overpass API Query I am trying to use (in Overpass Turbo Interface) is below:

[out:json];

area[name="Berlin"]->.b;
rel(area.b)[name="Tiergarten"];
map_to_area -> .a;

(
  way["building"](area.a);
  relation["building"](area.a);
);

// print results
out body;
>;
out skel qt;

The query like this is working, but I have an issue to solve.

I only want to select polygons (not POIs and not lines that have the tag "building"). This includes both polygons defined as ways and multipolygons defined as relations. But those multipolygon relations also include points and lines that I wish not to select (marked red in picture below)

How do I need to modify my query?

The POIs and lines to excluded from the selection

I tried to play with recursions, area sets and more closely defining tags, but without success. The reason to get "clean" selection like that is that I plan to use it repeatedly for some other cities and city districts.

I am fairly new to Overpass API.

4
  • @PolyGeo ♦ Hey PolyGeo, why is the question not specific enough? I it pretty specific with a lot of detail provided. If the problem why you closed it down is that it contains two questions I will delete the second one so you can reopen it. It made sense to me as it is one piece of code (to ask one question). Thank you.
    – Yanic
    Jun 9, 2017 at 9:50
  • The reason I voted this as being too broad is that it contains two questions which goes against the Tour. If one of those questions is removed then it will be fine to re-open it. That will necessitate the removal of one of the answers within @mmd's answer. Alternatively, there is nothing wrong with leaving your dual question with that dual answer, with the question closed so that it cannot be cited as an example by others not used to focussed Q&A.
    – PolyGeo
    Jun 9, 2017 at 10:28
  • @PolyGeo ♦ Thank you. The question is edited to only contain one question now. I edited the answer too and deleted comment of mine mentioning former Question no. 2. Could you reopen it now as I am still looking for an improved answer if possible.
    – Yanic
    Jun 9, 2017 at 15:31
  • @JanHavlas: based on the question above, I cannot really figure out, what else should be removed from the query result. You really have to add very specific examples.
    – mmd
    Jun 9, 2017 at 16:36

1 Answer 1

5

I would try the following query, which excludes building:part ways. That may still not be exactly what you're looking for, but it should give you an idea how to exclude some of the ways. In any case, it removes all the bits you marked in your screenshot above.

[out:json];

area[name="Berlin"]->.b;
rel(area.b)[name="Tiergarten"];
map_to_area -> .a;


way["building"](area.a);
out geom;

relation["building"](area.a);out;
way(r)[!"building:part"];
out geom;
2
  • The geometry type is an interpretation done by overpass turbo. For the actual Overpass API query, you need to do the filtering based on the OSM data model with its relations, way and nodes. So you probably want to investigate a bit further how the actual OSM raw data looks like and how you can adapt the filtering to match your requirements.
    – mmd
    Jun 8, 2017 at 15:32
  • Thanks for the explanation about Overpass Turbo! I understand the basics of OSM data model .. not all, but based on what I know I tried to tweek the query, but without success. Maybe someone else encountered simmilar issue.
    – Yanic
    Jun 8, 2017 at 15:37

Your Answer

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

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