The Anatomy of GPX files

Warning - this article is technical.

GPX files are created in XML

XML is an open standard to hold data in a text file. Computers work most efficiently with binary files, but these are not human readable. XML files can however be easily edited in a text editor, and can be interpreted and amended by people.

XML files are basically made up of tags. An example would be:

<name>My Route</name>

The <name> tells us what follows will be the tag ‘name’, and the </name> defines the end of the tag.

A Very Simple Example

<?xml version="1.0" encoding="utf-8"?>

<gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:q="http://www.anquet.com" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" version="1.1" creator="OMN2 - www.anquet.com" xmlns="http://www.topografix.com/GPX/1/1">

<Name>My GPX</Name>

<rte> <name>My Route</name> <rtept lat="53.6631532845088" lon="-1.96147696032491" /> <rtept lat="53.6630457942212" lon="-1.95906982338804" /> <rtept lat="53.6630453605849" lon="-1.95781231336069" /> </rte>

</gpx>

In the above, the top header is pretty complex, and you can just jump straight over it.

We then name the GPX file ‘My GPX’

<rte> then defines the start of the route.

<name> then names this route.

The route then contains three rtepts, with their lat and lon defined inside.

</rte> informs us we are at the end of the route.

</gpx> informs us this is the end of this simple GPX file.

Why know the internals of a GPX file?

There are lots of uses for being able to edit or understand the GPX file.

If you want to say load some data into Excel or similar, a GPX file can often supply you with the raw data, although in lat/lon, it might not be easy to work with.

If you have access to some data, cutting and pasting it into a GPX file may allow you to import it into say OMN or a GPS unit.

The major hint if you are looking to amend a GPX file by hand, and its new to you: say you want to import some waypoints. Plot one waypoint in OMN, and export the GPX file – that will give you a base file to work from. Add one more waypoint to it, and check you can open it in OMN. Then progress with the other imports.

Exporting clean GPX files from OMN

In OMN, we save an amount of extra styling data inside the GPX file, which can complicate reading it. If you have OMN Pro, in Settings->Options->GPS set it to USB Disk Device. Then use ‘Send to GPS’ on the GPS menu to output clean GPX files.

Further Reading

The GPX Standard: http://www.topografix.com/gpx.asp

XML : https://en.wikipedia.org/wiki/XML