OpenStreetMap – Converting Overpass Turbo Data to GeoJSON Without Map

boundariesgeojsonopenstreetmapoverpass-apioverpass-turbo

I would like to extract boundaries of some areas from Overpass Turbo in GeoJSON format.
At the moment I am using the website UI www.overpass-turbo.eu, write the query, execute it and export in GeoJSON format.

As the queries I am writing extract lots of information and taking into account that I always end with GeoJSON extraction (I don't need the map to be rendered) I am asking if it is possible to show in the right side of the side the GeoJSON and not the map (similar to when I say to output results in CSV).
Excluding the map rendere would be faster and assorbs less resources.

For example the following query gives me the boundaries of the Soho area in London: how can I execute it with GeoJSON output and not with a rendered map?

[out:json][timeout:25];
// gather results
(
  // query part for: “wikidata=Q124010”
  node["wikidata"="Q124010"]({{bbox}});
  way["wikidata"="Q124010"]({{bbox}});
  relation["wikidata"="Q124010"]({{bbox}});
);
// print results
out body;
>;
out skel qt;

Best Answer

If you're familiar with the command line:

  • Download boundaries as JSON (not GeoJSON!) file directly from Overpass API into a local file, via Export --> raw data directly from Overpass API in overpass turbo.
  • Convert the JSON file via a nodejs script from JSON into GeoJSON. In case you want to use the same library that is in place for overpass turbo, you should head to https://github.com/tyrasd/osmtogeojson for further instructions, or try the online demo http://tyrasd.github.io/osmtogeojson/

If you're unfamiliar with the command line, you might find administrative boundary relations in GeoJSON format for direct download https://wambachers-osm.website/boundaries/

Related Question