TrailCam

Guides

How to combine two GPX files into one track

Two recordings of what was really one walk is a common outcome — a phone restarted mid-hike, the app got force-quit, or a multi-day trek was logged a day at a time and you would rather have the whole thing as a single line afterwards. Joining them into one GPX file is mostly a matter of taking the points from the second file and adding them, in time order, to the first. Here is what that involves, and what it does and does not fix.

The short answer

A GPX track is nothing more than an ordered list of points inside a track element. Combining two tracks means taking the points from the second file and appending them, in chronological order, to the end of the first file's track segment, so a map or a service reads the result as one continuous recording instead of two. The underlying coordinates do not change; only how many files they are split across does.

How much work that is depends on the file. A short recording is small enough to merge by hand in a text editor. A full-day file with several thousand points is better handled by a tool built for it.

Why one walk ends up as two files

The most common cause is an interruption: the phone restarts to install an update, the battery dies and gets charged, or the recording app is force-quit by accident rather than stopped deliberately. Whatever was running before the interruption ends up saved as one file, and whatever runs afterwards becomes a second, with a gap of unknown length between them.

A multi-day trek is a different case and not really a problem at all — recording a day at a time, then stopping overnight, is the normal and sensible way to do it. The files are separate because the days were separate. Wanting one combined file afterwards, for a single upload or a tidier archive, is a choice made once the trip is over, not a mistake made during it.

If a TrailCam recording is ever interrupted mid-walk, it offers the unfinished route back to you the next time you open the app, rather than leaving you to reunite two separate files by hand afterwards. That removes the accidental case; a deliberate multi-day split is still yours to combine if you want to.

How to actually combine them

A merging tool

Browser tools such as GPX Studio can load two or more files onto the same map and export the result as a single track, with no need to touch the underlying XML. GPSBabel, a free command-line tool built specifically for converting and combining GPS data, will merge files in a single command if you are comfortable with a terminal. QGIS can do the same as a proper GIS operation, which is worth it once you are combining more than a couple of files at a time.

By hand, for a file small enough to read

Because GPX is plain text, a short file can be merged with nothing more than a text editor. Open both files, find the track segment in the second one, and copy every point inside it. Paste that block into the first file's track segment, just before its closing tag, so the two sets of points sit inside one segment rather than two separate files. Save the result with a .gpx extension and check it still opens — a missing or mismatched tag is the most common way this goes wrong.

What merging fixes, and what it does not

Merging solves the "two files" problem: a viewer or an upload page sees one track and reports one distance, one duration, one elevation profile, instead of asking which of two files you meant.

It does not close a gap between the files. If hours passed between the last point of the first recording and the first point of the second — an overnight stop, a drive, simply the phone being off — that gap becomes part of the merged file's elapsed time whether you account for it or not. If the two recordings overlap instead, covering the same stretch of ground twice, appending them naively produces two sets of points for the same few minutes, which shows up as an odd spike in distance or pace. Trimming the overlap out of one file before combining is worth doing in that case.

Work on a copy, keep the originals

Merge a duplicate of each file rather than editing the only copy you have. If a hand edit goes wrong — a stray character, a tag closed in the wrong place — you want to be able to start again from the unmodified originals rather than having lost the source data along with the mistake.

What TrailCam does

TrailCam can export a single route or your entire history as one GPX 1.1 file, or as a CSV summary, and can bring an existing GPX file back in. If a recording is ever interrupted mid-walk, it offers the unfinished route back to you when you return, which is what keeps most accidental splits from happening in the first place. Export is part of the optional TrailCam Pro upgrade; the app itself is free to download.

Questions

Will merging two GPX files confuse a service like Strava about distance or time?
Only if there is a real gap between the two recordings — a drive, an overnight stop, hours with the phone off. That gap becomes distance and time in the merged file exactly as it would if you compared the two files separately, so it is worth knowing it is there before you upload.
Can I merge a GPX track with a file that only has waypoints?
Yes, but they stay two different kinds of data sitting in the same file rather than combining into one. A track is a line; a waypoint is a single named point. Both can live in one GPX file without conflict, side by side.
Does it matter what order the two files' timestamps are in?
Yes. Points need to be in chronological order inside a track segment for a map to draw them correctly. If the second file simply continues after the first, appending it is enough. If the recordings overlap or are out of order, sort by timestamp before combining them.

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