Building a Custom Trail Map Using OSM and Mapbox

Here is an overview of the process I use for building my own custom hiking trail map. The data (trails, summits, etc…) are available as open source from OSM. MapBox Studio provides excellent tools for formatting and hosting GIS data pretty much anyway you want. The magic was in fetching the data and processing it to meet the needs of my user base. 

  1. Query TrailsNH to determine what areas I want to build a map for. Divide the area up into chunks (regions) to make processing manageable.
  2. Query OSM using the Overpass Turbo API, by region, by type of data I want (trails, peaks, etc…). This is where the Regions help, Overpass will time out if you select too much data. From this process I end up with a JSON file per Region.
  3. Clean up the data, apply local preferences, and generate merged GeoJSON file. The merger gets memory intense so I had to bump up the PHP memory limit from 128MB to 768MB.
  4. From here the data is put into TrailsNH DB where users will eventually be able to check off what they have hiked. The GeoJSON file is also imported into MapBox and map tiles are generated, using a custom map style.

The results are pretty good don’t you think?

Sample Custom Mapbox Map

You can see the results in an interactive (slippy) map, built using Leaflet and Mapbox. The interactive map also has live GeoJSON data added to it from TrailsNH, like: snow reports, trail advisories, and forest road closures.

Next Steps:

  • Add new user features to TrailsNH for red-lining trails and check off peaks climbed.
  • Include additional data types on the map, like: power lines, springs, camp sites, shelters, huts, view spots.

Published by


Kimball is a website designer and developer in Goffstown, NH.

Leave a Reply

Your email address will not be published. Required fields are marked *