Overpass – Exporting Buildings and Their Types to GeoJSON Using Overpass Turbo

exportgeojsonoverpass-turbo

I am trying to extract all buildings in one file within a certain city (Radebeul, Sachsen, Germany) from Overpass Turbo.

Example

My query looks as follows:

[out:json];

// fetch area “Radebeul” to search in
{{geocodeArea:Radebeul}}->.searchArea;

// gather results
(
  // query part for: “admin_level=*”
  node["admin_level"](area.searchArea);
  way["admin_level"](area.searchArea);
  relation["admin_level"](area.searchArea);
);
  // query part for: “building=*”
(
  way["building"](area.searchArea);
  relation["building"](area.searchArea);
);

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

The output:
Export_result

Everything looks okay, however, I can not understand why do my previously queried administrative districts disappear in the final output? I just want to visually check if buildings are within city borders.

Moreover, I was wondering what is the most acceptable file format for QGIS import? Is it GeoJSON? While I am not sure if Overpass Turbo will provide me with buildings types as well.


References:

Best Answer

You need an additional union statement, so that the final result contains the result from both subqueries. Otherwise, your second part of the query will overwrite the results of your first part of your query in memory, and you're losing the administrative boundaries in your result.

[out:json];

// fetch area “Radebeul” to search in
{{geocodeArea:Radebeul}}->.searchArea;


(                // added union here
  (
    
    nwr["admin_level"](area.searchArea);
    way["admin_level"](area.searchArea);
    relation["admin_level"](area.searchArea);
  );
    // query part for: “building=*”
  (
    way["building"](area.searchArea);
    relation["building"](area.searchArea);
  );
);                        // added union here
// print results
out body;
>;
out skel qt;

Try this query in overpass turbo! http://overpass-turbo.eu/s/FDb

For importing this data in QGIS, check out the "QuickOSM" Plugin!

Related Question