Thursday, April 05, 2018

HOWTO: Create a GPX trail from a non-georeferenced trail map image

There are various trail web pages that you can subscribe to for GPX files of almost all the trails in the US. However, if you are thrifty and would like to make your own for free, it is relatively easy to create a GPX trail that you can use on your watch or phone from a non-georeferenced trail map. For the curious techies, non-georeferenced simply means that the trail map has no metadata for placing the map in its appropriate location in a GIS (geographic information system) application. I'll now describe how to (1) georeference the trail map and (2) then hand-trace the trail into a GPX file. General instructions on how to georeference a raster image can be found here.

Initial Requirements

  • GIS application such as QGIS.
  • GIS base data layers for rivers, lakes, roads, county boundaries, etc. For example, Natural Earth Data has a lot of free 1:10 m national data layers you can download, and you can search Google to find State specific datasets such as these for Mississippi.
  • OPTIONAL, MMQGIS plugin for drawing latitude and latitude lines. This makes it easier to georeference the trail map but is not required because you can instead use other geographic features such as rivers and roads.

Initial Setup

If you are already familiar with GIS, feel free to use or make your own base map for the area of interest and skip to the Georeferencing the Map section below.
  • Create map with base Layers
    • Download and save base layers to hard drive. I recommend using at least a county layer, a river layer, a lake layer, and a road layer.
    • Create project in GIS application.
    • Add base layers to project.
    • Reorder base layers so that, for example, the county layer acts as a base for your roads and river layers.
    • Change rendering of layers so that, for example, rivers are blue and roads are gray.
    • OPTIONAL, change the coordinate reference system (in QGIS go to Project > Project Properties > CRS) of the base map to a regional projection for the area of interest. For the Tuxachanie Trail in Mississippi, I used a NAD83 (North American Datum 1983) East Mississippi projection.
Example base map for Harrison County in East Mississippi

  • OPTIONAL, create lat/long grid lines. In QGIS, the MMQGIS plugin (in QGIS, go to Plugins >> Manage and Install Plugins) can be used for this purpose and is pretty self-explanatory. The grid lines are probably going have to be pretty small (0.05 degrees or smaller), so be sure you are zoomed in and don't overdo the extent when generating the lines. The grid lines can be used when adding georeference points as described below.

Georeference Image in QGIS

  • If necessary, install Georeferencer GDAL plugin (Plugins >> Manage and Install Plugins).
  • Obtain the highest resolution image of trail map possible. I recommend doing a Google Image search and then filtering for large sized images.
  • Initiate GDAL plugin (Raster >> Georeferencer >> Georeferencer).
  • Add at least four georeference points at easily identifiable locations (road or river intersections, intersecting grid lines, etc.).  Find the same location on Google Maps (right-click to drop a point in Google Maps at georeference point and use X and Y coordinates of point) to determine the coordinates for each georeference point.
Example georeferencer points (little red dots that are difficult to find)

  • "Start Georeferencing" to execute plugin and generate georeferenced raster, which should be automatically added to your map project.
Georeferenced raster with base map confirmation

Convert Trail Map to GPX

  • Create a new empty shapefile layer of line type.
  • Enable editing by toggling editing of the new line layer.
  • Create a new feature and trace the trail image to add all the vertices to a single polyline. In QGIS, you can use the arrow keys to pan the map while zoomed in.
  • Save edits in the new line layer.
  • Export the line layer to GPX (Layer >> Save as). In the Save As dialog, select GPX as the format, specify a filename, and deselect any attributes before running export.
Final product

No comments:

Big Basin Backpacking Trip - Californication Achieved in 30 Miles

Trip Overview Big Basin is a State Park with a plethora of trails and majestic redwoods. My hike was a 30ish mile loop starting at t...