Building a Custom Trail Map Using OSM and Mapbox

Here is an high level overview of the process I use for building my own custom hiking trail map. The data I’m using (trails, summits, etc…) are available as open source from OSM. After I fetch and clean up the data I use MapBox to generate the map tiles, in a map style I designed. 

  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 1 JSON file per Region, per data type.
  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 goes two ways:
    1. Put into the TrailsNH DB for searching place names and other uses.
    2. Imported into MapBox for generating map tiles, using a custom map style I designed.

The custom trail map looks pretty good don’t you think?

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:

  • Include additional data types on the map, like: power lines, springs, camp sites, shelters, huts, view spots, and waterfalls.
    • Done/Added: springs, camp sites, shelters, huts, view spots.
  • Add new userĀ features to TrailsNHĀ using the new data:
    • Peaks climbed map (shareable)
    • Red-lining trail map (shareable)
    • Custom Route planning map

Published by


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

2 comments on:
“Building a Custom Trail Map Using OSM and Mapbox”

  1. Pretty cool, thanks for posting! I’m trying to figure out how to get trail data from overpass, but not having much luck.

    1. Did you try the Overpass Wizard? You can use it to help define a search for lines tagged as footpath. Run it on a region with hiking trails.

      If you have a specific error or question I may be able to help.

Leave a Reply

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