Skip to content

Instantly share code, notes, and snippets.

@planemad
Last active October 10, 2021 03:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save planemad/314c953c7827c2466003 to your computer and use it in GitHub Desktop.
Save planemad/314c953c7827c2466003 to your computer and use it in GitHub Desktop.
Creating custom OSM based maps using Mapbox

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
@Andygol
Copy link

Andygol commented Mar 10, 2016

@planemad
You're just in time
I am preparing presentation about using Mapbox Studio (how to obtain data form OSM and style it) for the GIS-Forum

👍 💥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment