Tuesday 19 December 2017

openstreetmap - Overpass API: Select all building polygons (excluding POIs and lines) within certain area


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.



Answer



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;

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...