TrailCam

Guides

GPX vs polyline for trail data: which one fits a hike?

An encoded polyline is not a file in the way GPX is a file — it is a single line of text, a compressed string of characters that a mapping API sends back to draw a route on a map without the overhead of a full list of coordinates. GPX is a document that describes a recorded track point by point, with a timestamp and an elevation riding along with each one. The two are built for different jobs, and only one of them is built to hold what happened during a hike.

What a polyline actually is

The polyline most people run into is Google's Encoded Polyline Algorithm Format, the same scheme used across most mapping and routing APIs that need to hand a route's shape back in a response. It takes a list of latitude and longitude pairs, rounds each one to five decimal places, stores only the difference from the previous point rather than the point itself, and packs the result into a short run of ASCII characters using a base64-like alphabet. A route that might take a few kilobytes as a plain list of coordinates can come back as a polyline a few hundred characters long.

That string is not meant to be opened, read, or kept on its own. It exists to travel inside a JSON response or a URL parameter, get decoded back into a list of points by whatever drew the map, and then be thrown away once the map has rendered. It is a shape in transit, not a record.

What GPX holds that a polyline has no room for

A GPX track point carries a timestamp and an elevation alongside its position, and depending on the device, a few extra fields like GPS accuracy tucked into an extensions block. None of that fits into a polyline at all — the format was designed to answer one question, where does the line go, and nothing else. Strip the timestamps out of a hike and there is no way to work out how long it took, what the pace was at any point, or which stretch was moving time and which was a stop. Strip the elevation out and there is no profile, no gain, no loss. A polyline answers the where. It has nothing to say about the when or the how high.

Why precision gets rounded off, too

The five-decimal-place rounding built into the standard polyline encoding is itself a small, deliberate loss — on the order of a metre at the equator, traded away because the API responses it serves are meant for drawing a line on a screen, not for measuring a route precisely. That trade makes sense for what a polyline is used for. It stops making sense the moment the goal shifts from showing a route to measuring one, which is exactly the shift that happens when a walk becomes a hike you want a real distance and elevation figure for, rather than just a line on a map.

Side by side

  • Structure: GPX is a full document, one point per entry, each carrying its own timestamp and elevation. A polyline is a single encoded string with no timestamps and no elevation at all.
  • Origin: GPX is an open, vendor-neutral format published in 2002 for GPS devices. The encoded polyline format was published by Google for its Maps API, to keep route shapes small inside API responses.
  • Compatibility: GPX opens in almost any mapping, GIS, or GPS tool built to read a track file. A polyline needs a decoder built for that specific encoding before it becomes usable at all.
  • Best fit: GPX for a recorded hike you want to keep, measure, or import elsewhere. Polyline for passing a route's shape briefly between a server and a map.
  • Readability: GPX is plain XML text, readable by eye. A polyline is an opaque run of characters — accurate but meaningless without running it through a decoder.

Converting between them

Turning a GPX track into a polyline is a one-way trip. A handful of libraries and online tools will read the coordinates out of a GPX file and encode them into a polyline string, but everything that made the GPX file useful for reviewing a hike — the timestamps, the elevation, the point-by-point detail — has nowhere to go in the target format, and gets left behind. What comes out the other end draws the same shape and nothing more.

Going the other way is worse than lossy, because there is nothing left to lose. Decoding a polyline back into coordinates gives you a bare list of latitude and longitude pairs, since no timestamp or elevation was ever stored to recover. Rebuilding a GPX file from that means inventing the missing pieces rather than recovering them — spacing out fake timestamps evenly along the line, say — which produces a file that looks like a recording without actually being one.

Where TrailCam fits in

TrailCam exports a recorded route as GPX 1.1 or as a CSV summary, both of which keep the timestamp and elevation on every point rather than reducing a hike to a bare shape. That is the difference that matters for a hike you want to review afterwards, bring into another tool, or hold onto as a real record rather than a line a map happened to draw once. GPX and CSV export are part of the optional TrailCam Pro upgrade; the app itself is free to download.

Questions

Is a polyline the same thing as a GPX file?
No. A polyline is a single compressed string that encodes only the shape of a route — no timestamps, no elevation, nothing beyond where the line goes. A GPX file is a full document with a timestamp and an elevation on every recorded point.
Can you get pace or elevation gain out of a polyline?
No, and there is nothing missing to go find — a standard encoded polyline never held a timestamp or an elevation value in the first place, so there is no pace, moving time, or elevation gain to recover from one.
Does TrailCam export routes as a polyline?
No. TrailCam exports a recorded route as GPX 1.1 or as a CSV summary, both of which keep the full point-by-point timing and elevation a polyline was never built to carry.

Recording your own routes

TrailCam is an iPhone app that records your route with GPS, keeps video clips, photos and voice notes pinned to the spot where you took them, and exports the result as GPX 1.1 or CSV. It is free to download.

Download on the App Store