Skip to content

Instantly share code, notes, and snippets.

@Andygol
Forked from planemad/overpass.md
Created March 13, 2016 21:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Andygol/1064e55ed625f14401a2 to your computer and use it in GitHub Desktop.
Save Andygol/1064e55ed625f14401a2 to your computer and use it in GitHub Desktop.
Uploading OSM data to Mapbox using an overpass query

If you have been playing around with the new Mapbox Studio you might be interested to know how to make a custom map with objects of your own interest from OpenStreetMap.

To make the process of creating an updating an OSM based dataset on Mapbox more seamless, I was looking into a command line based workflow that could extract OSM data from Overpass and update a Mapbox hosted dataset in one go.

Requirements

Generate an Overpass Query

  • Use Overpass Turbo to create a query for the data you are interested in extracting. Since i'm interested in bus stops, I first browse the map to Bengaluru, India and then generate a query using the wizard query highway=bus_stop
  • Test your query by confirming that the results on the map are as expected
  • Export the query in compact form and save the resulting query to a query.ql file [out:json][timeout:25];(node["highway"="bus_stop"](12.946554043930224,77.56158828735352,12.983816808126269,77.62420177459717););out body;>;out skel qt;
    screenshot 2016-01-22 18 16 54

Update your Mapbox dataset using the Overpass query

  • In terminal run query-overpass query.ql --flat-properties > output.geojson to download the OSM features into a geojson file
  • Run mapbox upload mapbox_username.mapid output.geojson to create or update a dataset on Mapbox with the geojson.

Known bugs

Verify your upload on Mapbox

  • Visit the Mapbox data page to check the status of your upload
  • Once uploaded, open the dataset and add it to your map
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment