Skip to content

Instantly share code, notes, and snippets.

@joeyklee
Created September 28, 2017 14:03
Show Gist options
  • Save joeyklee/0dae9a81a2b0b6e0540acd3f496b4d0a to your computer and use it in GitHub Desktop.
Save joeyklee/0dae9a81a2b0b6e0540acd3f496b4d0a to your computer and use it in GitHub Desktop.
Quickly get data from overpass turbo to geojson

Quickly get stuff from OSM & Convert to Geojson

Overpass turbo:

In the query box, for example:

/*
This has been generated by the overpass-turbo wizard.
The original search was:
“highway=primary”
*/
[out:json][timeout:25];
// gather results
(
  // query part for: “highway=primary”
  way["highway"="primary"]({{bbox}});
  way["highway"="motorway"]({{bbox}});
  // query part for: “highway=primary”
  way["highway"="secondary"]({{bbox}});
  // query part for: “highway=primary”
  way["highway"="tertiary"]({{bbox}});
  way["highway"="residential"]({{bbox}});
  way["highway"="unclassified"]({{bbox}});
);
// print results
out body;
>;
out skel qt;

BUT instead of RUN ==> EXPORT ==> raw data directly from Overpass API ==> save file .json

Convert to geojson using osm2geojson npm module:

Install:

npm install -g osmtogeojson

Run:

osmtogeojson output.json > output.geojson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment