I have used Google Maps to build a list of waypoints for a trail I want to hike but the waypoints are simply my start, end and maybe a couple of points of interest for my day and any campgrounds along the route.

I now have all of this data in a GPX file for importing into my GPS, but it keeps reporting distance as the crow flies to the next waypoint instead of distance along the trail. I have since learned that the fix is to add a metric boatload of waypoints to my tracks.

Is there any way to auto-generate waypoints along the track line between two existing waypoints that follows the trail line instead of line-of-site?

I keep seeing people pointing to GPSBabel (but that only does line-of-site) or suggestions to manually add points.

  • 1
    The open source software QGIS has a tool called "points along lines" which will generate as many points as you want along a curved line.
    – csk
    Commented Sep 5, 2018 at 18:48
  • 1
    It seems that the fundamental problem is that Google Maps is not designed for what you're trying to do. Try a GIS program. Here are a few suggestions, in increasing order of difficulty to learn. Google Earth is extremely quick to learn, but not very versatile. Garmin BaseCamp is relatively user-friendly, and probably capable of what you want. QGIS is definitely capable, but can take a while to learn. Once you pick a program, the GIS SE community can help with any questions you have using that program.
    – csk
    Commented Sep 5, 2018 at 18:58
  • Ok, thanks. I'm going to check the QGIS tool to see how that goes. Please feel free to list that as an answer though and if it works out I'll approve it.
    – Bryan C.
    Commented Sep 5, 2018 at 18:59
  • Do you have the trail as a GPX file? Or do you only have points along the trail?
    – csk
    Commented Sep 5, 2018 at 19:06
  • I have the trail as a GPX file but the trail only has a couple of waypoints on it, I need to fill in waypoints so I can get accurate distance calculations to my destination while hiking.
    – Bryan C.
    Commented Sep 5, 2018 at 19:07

2 Answers 2


Using QGIS 3.2

Add a base map

Install the plugin QuickMapServices.

Plugins menu > manage and install plugins > find and install Quickmapservices

enter code here

The QuickMapServices button is on the Manage Layers toolbar. Click this button, and add a base map. OSM Standard is a good option.

enter image description here

Import the trail GPX file

Drag the GPX file into the QGIS window. QGIS will ask which parts of the GPS you want to import. Import the route or track, whichever one has features. In my example, the trail is stored a route.

enter image description here

Now you have a line layer called "trailname_routes" (or "trailname_tracks").

Make sure that the trail shows up at the correct location relative to the basemap.

Re-project the trail layer into a projected coordinate reference system

Your GPX file is probably in the standard geographic coordinate system WGS84. This system uses latitute and longitude decimal degrees. In order to do a distance calculation in feet or meters, we need to project the layer into a coordinate reference system that uses those units. If your file is already in a projected coordinate reference system, skip this step.

Right click on the "trailname_routes" in the layer panel. Choose Export > Save features as...

Click the button next to CRS enter image description here

Choose an appropriate projected CRS. I'm assuming your trail is in the US. In the Coordinate Reference Selector window, search for the name of US state that the trail is in. Choose the local CRS with the units you want to use for distance calculations. (If you want to do calculations in feet and miles, choose one that uses ftUS as its units. If you want to use meters, choose one that uses meters.)

Choose one with NAD83 or NAD_1983 in the name. Avoid any with "deprecated" in the name. Don't worry about the difference between "HARN" and "FIPS."

For example, for a trail in western Maine, and distance calculations in feet, I would choose this one:

enter image description here

Save the trail somewhere on your computer. This file is just for calculations, you won't need to upload it to your GPS.

Add points along the trail at fixed distance intervals

Decide how far apart you want these points, in the units of the CRS. For example, if you want a point every mile along the trail and your CRS uses feet, you would want them 5280 feet apart. Every half mile would be 2640 feet apart.

Open the Processing toolbox (Processing menu > toolbox). Search for "points along geometry". Double click to open this tool.

For input layer, choose the projected trail layer that you created in the last step. For distance, input the distance you calculated, eg 5280 feet. Run the tool.

Now you have a layer of points spaced 1 mile apart along the trail.

enter image description here

Preserve the distance value

The distance along the line is saved as an field called "distance". GPX format only allow specific fields. When exported to GPX format, the "distance" field will be deleted. So we have to copy the distance values into one of the fields that will be saved. The "name" field is usually the one displayed as a label on the GPS device, so we'll copy the distance value into the 'name' field.

Use the Field Calculator to update the "name" field with the expression "distance"

Or you might want to round the distance value if it has a lot of decimal places. In that case, use the expression round("distance", n) where n is the number of decimal places you want.

If you want to convert from feet to miles, use the expression "distance"/5280 or round("distance"/5280, n).

enter image description here

Export the marker points layer in GPX format

Choose WGS84 as the CRS.

Unselect all fields below "link2_type". If you get an error message like the one below, go back and unselect the field that it mentioned :

Export to vector file failed. Error: Creation of field number failed (OGR error: Field of name 'number' is not supported in GPX schema. Use GPX_USE_EXTENSIONS creation option to allow use of the element.)

Import the distance marker points into your GPS

Make sure the distance value is displayed as labels for these points. If not, you should be able change a setting in the GPS to make it use the "name" field as a label. Otherwise you'll need to figure out which field of the GPX is used for labels, and go back into QGIS and put the distance value in that field.

  • Perfect. I just finished slogging through this on my own and figured most of this out then came back to find you're guide. Doh. But you've got more detail here so even better. Thanks! This appears to have done exactly what I needed. For what it's worth I did my approach with the "Locate points along lines" plug-in but you're method looks like it's doing the same thing and has better options.
    – Bryan C.
    Commented Sep 5, 2018 at 20:31
  • 1
    I just realized that my solution would display the distance in the original CRS units. You probably want to convert from feet to miles or from meters to kilometers (or the screen will get cluttered pretty quickly). I edited my answer to include conversion instructions.
    – csk
    Commented Sep 5, 2018 at 21:01

Graphhopper might be a better route for you...

Example: Hiking, Oregon Coast Trail (a small section of)

enter image description here https://graphhopper.com/maps/?point=45.803106%2C-123.963675&point=45.786021%2C-123.959298&point=45.790689%2C-123.917584&locale=en-US&vehicle=foot&weighting=fastest&elevation=true&use_miles=false&layer=TF%20Outdoors

and select the tiny [gpx] text to export to gpx

(only as good as the data in OpenStreetMap. If your route is not there please add it).

  • 1
    Thanks. I'll take a look at this and see if it can help.
    – Bryan C.
    Commented Sep 5, 2018 at 19:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.