TrailCam

Guides

How to convert a CSV file to GPX

This is the harder direction of the two. Converting a GPX file to CSV only ever throws information away, which is safe and mostly mechanical. Converting a CSV file to GPX asks for the opposite: rebuilding a route's shape out of a table that may never have held one in the first place. Whether it can be done at all depends entirely on what is already sitting inside that particular CSV — and for a lot of CSV files, the honest answer is that it cannot be done.

The short answer

A CSV can only become a usable GPX track if it already has one row per recorded point, with columns for latitude and longitude at minimum, ideally elevation and a timestamp too. A tool that can read that table and write GPX's XML structure — a GIS package such as QGIS, a spreadsheet macro, or a short script — then turns each row into a track point in order. If the CSV instead holds one row per hike, with columns like distance, duration and elevation gain, there is no route shape inside it to work with. A summary was never a track to begin with, and no conversion tool can invent the missing points.

Two very different kinds of CSV

A per-point CSV

One row for every recorded point, with latitude and longitude in their own columns, ideally elevation and a timestamp alongside them. This is the only kind of CSV that a route can actually be reconstructed from, because it is the only kind that still contains the geometry — the same information a GPX track point holds, just sitting in a different container.

A summary CSV

One row per hike, with columns for things like date, distance, duration and elevation gain. This is what most CSV exports actually are, because it is what most people want a spreadsheet for. It is also, for this particular purpose, a dead end: there is exactly one row of numbers describing an entire route, and a route's shape cannot be pulled back out of a total.

What has to survive the conversion

Latitude and longitude are the minimum a converter needs to draw a line at all. Elevation is optional in the sense that GPX allows a track point without it, but if the source CSV never had an elevation column, the resulting GPX will not have elevation either — a conversion tool has nothing to invent that number from. A timestamp on each row matters more than it looks: GPX track points are read back in the order they appear in the file, so if the CSV rows are not already sorted chronologically, the rebuilt route can zigzag between points that were recorded minutes apart.

The spreadsheet habit that quietly corrupts coordinates

Opening a coordinates CSV in a spreadsheet program to check it, and then saving it again, is a common way to damage the very data you are trying to convert. Spreadsheet software is built to make numbers tidy, which for a normal column of figures is helpful and for a column of GPS coordinates is not: it can round off decimal places you needed, or silently switch a long decimal into scientific notation. A coordinate that loses even a few decimal places can shift by a noticeable distance once it is plotted on a map. Editing the file in a plain text editor, or a tool built to handle coordinates specifically, avoids the problem entirely.

Why keeping the original GPX is the easier path

The situations where this conversion genuinely comes up are narrower than they might seem: someone kept only a CSV summary and no longer has the source track, or received route data from somewhere as CSV and needs GPX to get it into a mapping tool that requires that format. If the original GPX file still exists anywhere, using it directly is simpler and more reliable than rebuilding one from a table that was only ever meant to hold totals. CSV to GPX is worth attempting only once the GPX itself is genuinely gone.

Things that trip people up

  • Expecting a summary CSV — one row per hike — to turn into a track: there is no geometry in a summary to convert, whatever tool is used.
  • Assuming any spreadsheet program can do this conversion on its own: CSV has no fixed structure the way GPX does, so a converter has to be told exactly which column is latitude, which is longitude, and which is time for that specific file.
  • Coordinates changing slightly after a CSV has been opened and re-saved in a spreadsheet: a formatting side effect of the spreadsheet program, not a fault in the original data.
  • A rebuilt GPX with no elevation profile: this happens whenever the source CSV never had an elevation column, not because the conversion went wrong.

Where TrailCam fits in

TrailCam exports the same recorded route as GPX 1.1 or as a CSV summary, straight from what it recorded — neither one is derived from the other after the fact. That means this conversion never has to happen for a route recorded in TrailCam: if GPX is what a mapping tool needs, it is already sitting there next to the CSV, not something to be rebuilt from it. Export is part of the optional TrailCam Pro upgrade; the app itself is free to download.

Questions

Can any CSV file be turned into a GPX track?
Only if it already has one row per recorded point with latitude and longitude columns. A summary CSV — one row per hike — has no route geometry in it, so there is nothing for a converter to turn into a track.
Will elevation come through when converting CSV to GPX?
Only if the source CSV already had an elevation column. A GPX file built from a CSV can never contain more than the CSV itself provided — there is nothing for a conversion tool to invent elevation from.
Why do coordinates sometimes change after editing a CSV in a spreadsheet?
Spreadsheet programs can reformat number columns automatically, rounding decimals or switching to scientific notation, which silently shifts GPS coordinates. Editing the file as plain text avoids the problem.

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