Merge several GPX tracks

The three-day hike, the watch that split the activity, the phone that died halfway: here the pieces become one file, lined up by time and not by file name.

Tap here or drop the GPX files
The files stay in your browser: they are not sent anywhere.

When you end up with several files, and why pasting them does not work

The case is not «I have two files», it is almost always one of these four. The multi-day hike, where the watch saves one activity per day and in the end you have five of them instead of the route. The activity split by the break: you stopped to eat, you pressed stop, and when you started again a new file was born. The phone that died halfway, which started recording from scratch as soon as you plugged it into the power bank. And the bike computer that saves on every power-up, so a ride with three stops is four files.

All four end the same way: the portal where you want to upload the track expects one single activity, and you have five. Pasting the files together in a text editor does not work, because a GPX is not a list of lines: it is an XML document with a structure of its own, and two documents stuck one after the other are not a document. They have to be taken apart and put back together, and that is what this page does, inside your browser, without the files leaving the device.

It takes GPX and TCX, compressed in .gz too, which is what comes out of a Garmin watch or a trail portal. What comes out is always a GPX, because that is the format everybody reads.

The order is the one on the clock, not the one of the names

This is the first mistake, and it is a silent one. If the files are called ride (1), ride (2) and ride (10), in alphabetical order the ten sits in the middle, between the one and the two: a program that sorts by name joins the pieces in the wrong order, and out comes a track that jumps forward and then doubles back. On the map you see it at once; in the elevation and distance figures you do not, and those are the figures you go on to tell people.

Here the order is read inside the files: every recorded point carries its timestamp, and the pieces are lined up by starting time. The file name counts for nothing, and it must not count: it is something the phone decides, not you.

When the timestamps are not there the page says so instead of guessing. It happens with routes exported from a planner, which are a line drawn on a map and not a recording: there is no «before» and «after» to read there, so the order you loaded the files in stays, and you can correct it with the arrows. Guessing would be worse: a wrong order that declares itself can be seen, a wrong order presented as right cannot.

Two ways of joining, and they are not the same thing

One segment per file is the recommended way, and it keeps the gap for what it is. Inside the GPX the pieces stay separate, and nearly every program that works out moving time skips the intervals between one segment and the next: the night spent in the hut does not end up in the elapsed time and the stretch between the end of one day and the start of the next is not drawn.

A single segment joins everything into one continuous line. It is right when the gap is a hiccup, when the watch played up for thirty seconds and the two pieces touch. It is wrong when there is a night between one file and the other, because the program draws a straight line from where you were to where you reappeared, and those crow-flies kilometres go into the total as if you had walked them.

The difference is not an opinion, it is a number. On the same two days of the test files, the separate-segments way gives 4.33 km and the single-segment way gives 5.30 km: nearly a kilometre out of nowhere, which is exactly the crow-flies stretch between the point where the first day's recording ended and the one where the second day's began. That is why the page, before you choose, tells you for every junction how many metres as the crow flies and how much time there are: with those two figures in front of you the choice takes a second.

What does not get lost on the way

This is the part that tells a real merge from one done for show, because the damage is invisible: the file opens, the track is there, the map is right, and the training data is gone. Inside every recorded point, besides elevation and time, travel the extensions: heart rate, cadence, power, temperature. Here they are copied across point by point, and at the end the page tells you on how many points it found them, so if the number is zero you know it before uploading and not after.

Same for the waypoints, that is the dots somebody placed by hand: the hut, the spring, the fork where everybody gets lost. They are the only thing in the file that a machine did not write, and a merge that throws them away deletes the only human work that was in there. The ones that turn up in two files with the same name and the same coordinates go in only once.

And the fields almost nobody looks at but that come from the receiver are kept too: hdop, sat, fix, that is how many satellites were locked and how good reception was at that point. They are no use to you, they are of use to the programs that later have to decide which points to trust.

The file that comes out is GPX 1.1, and this is not a claim made in words: the test for this tool hands the produced file to the official schema, which is the specification itself, and demands that it be accepted. It is needed because inside a point the order of the fields is compulsory, and a file with the fields in a different order opens perfectly well in a text editor and gets refused by the portals, which when they refuse never explain why.

What it does not do, said plainly

It does not invent points. Where there is a gap a gap stays: the page does not interpolate, does not draw a plausible curve between the end of one piece and the start of the next, does not reconstruct the missing stretch. If you choose the single segment, the straight line is drawn by the program you open the file with, and you know it up front because you were told here.

It does not clean up GPS noise. If a track has that classic fifty-metre spike because you were under a roof, that spike stays. To look at what is inside a track — real distance, elevation gain with a threshold against the noise, gradients and the elevation profile — the right page is GPX track analyzer.

It does not do the opposite job. Splitting a track into pieces is another trade and it is not here. And it does not touch the elevations: if your watch gets them wrong by twenty metres, they come out wrong by twenty metres afterwards too, because correcting them would mean having a model of the terrain and making the difference up.