GPX Files Explained: How GPS Tracks and Stores Your Routes

I enjoy going on small to medium hikes with my family, and we recently bought a GPS tracker to keep track of our journeys. In the past, we relied on various smartphone apps, but being the nerd I am, I wanted to record the routes myself and use the data for future experiments. Since I had never worked with the GPX file format before, I figured this would be a great opportunity to dive in and share what I learned along the way. Have fun!
GPX Files Explained: How GPS Tracks and Stores Your Routes

What Is GPS and How Does It Work?

GPS stands for Global Positioning System and is owned by the United States Space Force (which is a pretty cool sounding name for a branch of the US military). It allows GPS receiver modules to determine their position on Earth as well as access highly accurate time information.

The system relies on a constellation of at least 24 satellites orbiting the Earth in medium Earth orbit (MEO), each completing roughly two orbits per day. A GPS receiver calculates its position by measuring the time it takes for signals from multiple satellites to reach it. With signals from at least four satellites, the receiver can compute its exact location (latitude, longitude, and altitude) along with precise time. This process is often referred to as trilateration.

In short, GPS works by turning time signals from space into a precise position on Earth—something we now rely on every day, often without even thinking about it.

Pretty cool, isn't it?

How Is a GPX File Structured?

Another three-letter abbreviation: GPX stands for GPS Exchange Format. At its core, a GPX file stores geographic coordinates, usually in a time-ordered sequence.

To achieve this, a GPX file is typically divided into three main sections:

  1. A waypoint (wpt) represents a single point of interest at a specific coordinate. Depending on the device, additional data (like heart rate or metadata) can also be stored.
  2. A route (rte) describes a planned path from a starting point to a destination. It consists of a sequence of route points that define the intended direction.
  3. A track (trk) represents the actual recorded path. It can contain multiple track segments (trkseg), each made up of many track points (trkpt) that include coordinates, timestamps, and optionally elevation.

All of this information is stored in an XML structure. Here’s an example from one of my test walks:

<?xml version="1.0" encoding="UTF-8"?>
<gpx version="1.1" creator="Columbus GPS - http://cbgps.com/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://www.topografix.com/GPX/1/1"
    xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
    <trk>
        <name>2026-04/06111710.GPX</name>
        <trkseg>
            <trkpt lat="48.9986035" lon="9.0783333">
                <ele>206</ele>
                <time>2026-04-06T09:17:15Z</time>
            </trkpt>
            ...
        </trkseg>
    </trk>
</gpx>

In this example, the device records only the essentials: latitude, longitude, elevation, and timestamp. That’s enough to reconstruct the route. More advanced devices may include additional data such as heart rate, cadence, or temperature within the same structure.

What Can You Do With a GPX File?

Once you have a GPX file, it becomes surprisingly versatile. Many apps and tools can import GPX data to visualize your route on a map, analyze your performance, or share your journeys with others.

For example, you can load a GPX file into mapping software to see exactly where you went, calculate total distance or elevation gain, or even replay your hike step by step. Some fitness tools also use this data to estimate speed, pace, or calories burned.

In my case, the interesting part is having full control over the raw data. Instead of relying on app summaries, I can run my own analysis—whether that’s plotting elevation profiles, comparing routes, or experimenting with the data in small lab projects.

How to Work With GPX Data Programmatically

Because GPX is based on XML, it’s relatively easy to process with most programming languages. You don’t need anything fancy. Just a standard XML parser is enough to extract the data you’re interested in.

A typical workflow might look like this: read the file, iterate over all track points (trkpt), and collect values like latitude, longitude, elevation, and timestamp. From there, you can compute distances, speeds, or even generate your own visualizations.

What I really like about GPX is its simplicity. The structure is predictable, human-readable, and flexible enough to include additional data if needed. That makes it a great format not just for recording routes, but also for experimenting and learning.

Where I am going with it

And that's exactly where I'm heading: I currently plan to write a small visualizer for the GPX files I record. If you like to follow me on this journey be sure to subscribe to the newsletter or check in on the blog every now and then.

Thanks!