GEOO.APPGEOO.APP
Back to all posts
2026-11-0627 min readGPXGPSGeoJSONKMLCSVtracksrouteswaypoints

GPX Files Explained: Tracks, Routes, Waypoints, and Converting to GeoJSON/KML/CSV (Measured)

A practical guide to the GPX GPS format: what waypoints, tracks and routes are, how they map to GeoJSON, the coordinate-order trap, GPX 1.0 vs 1.1, and measured output sizes when converting one real 769-byte GPX to GeoJSON, KML and CSV in the browser.

If you have ever taken a hike with a Garmin, recorded a bike ride on a phone, exported a survey path from a handheld unit, or downloaded a trail from OpenStreetMap, you have a GPX file. GPX — the GPS Exchange Format — is the closest thing the GPS world has to a universal file. It is the format Garmin, Strava, OSM, and a thousand apps all speak, and it is the first thing you reach for when you want to get a recorded path off a device and into something you can actually map, analyse, or share.

But "universal" does not mean "obvious." A GPX file can hold three completely different kinds of geometry at once, it can be written in two different schema versions, and converting it to something a web map or a spreadsheet can use is exactly where people get stuck. This article explains what is actually inside a GPX, how its three element types become GeoJSON features, where the coordinate-order trap lives, how GPX 1.0 differs from 1.1, and then measures the real outputs of converting one genuine 769-byte GPX to GeoJSON, KML, and CSV on geoo.app. Every number below is measured, not approximated.

GPX at a glance

Figure 1. One GPX, three exports, measured in the browser.

1. What a GPX file is

GPX is an XML schema (version 1.1, originally published by Topografix and now widely supported by OpenStreetMap tooling and virtually every GPS vendor) for storing waypoints, tracks, and routes produced by GPS devices. It is plain text, it is human-readable, and it is almost always in WGS84 longitude/latitude — which means, unlike a DWG or a Shapefile in a projected grid, you can usually plot it the moment you have it. That single property is why GPX is the default interchange format for anything that came off a GPS receiver.

A minimal GPX looks like this (this is the real sample we will measure throughout the article):

<?xml version="1.0" encoding="UTF-8"?>
<gpx version="1.1" xmlns="http://www.topografix.com/GPX/1/1">
  <wpt lat="40.0" lon="-105.0">
    <name>Waypoint A</name>
    <desc>A test waypoint</desc>
    <sym>flag</sym>
  </wpt>
  <wpt lat="40.5" lon="-104.5">
    <name>Waypoint B</name>
  </wpt>
  <rte>
    <name>Route 1</name>
    <rtept lat="39.0" lon="-106.0"><name>Start</name></rtept>
    <rtept lat="39.5" lon="-105.5"><name>Middle</name></rtept>
    <rtept lat="40.0" lon="-105.0"><name>End</name></rtept>
  </rte>
  <trk>
    <name>Track 1</name>
    <trkseg>
      <trkpt lat="41.0" lon="-107.0"></trkpt>
      <trkpt lat="41.5" lon="-106.5"></trkpt>
      <trkpt lat="42.0" lon="-106.0"></trkpt>
    </trkseg>
  </trk>
</gpx>

1.1 Where GPX files actually come from

It helps to know why you have a GPX in the first place, because the source tells you which of the three element types you should expect inside:

Knowing the source answers the first question a converter raises: "is this a record of where I went (track), a plan of where I intend to go (route), or a set of points (waypoints)?" Those three are not interchangeable, and conflating them is the single most common GPX mistake.

1.2 Why GPX and not just GeoJSON or KML?

You might reasonably ask why GPS devices do not just write GeoJSON. The answer is that GPX was designed in an era when devices were tiny and needed a forgiving, self-describing text format that could carry time and elevation alongside position, and that could separate "where I went" from "where I planned to go." GeoJSON has no native concept of a track versus a route; KML does, but KML is heavier and less uniformly supported by embedded GPS firmware. GPX sits in the sweet spot: small, widely supported, and semantically rich for GPS use. You convert out of GPX when you need a map, a spreadsheet, or a web API — which is the whole subject of this article.

2. The three element types

GPX distinguishes three geometries, and mixing them up is the most common conversion mistake:

In our sample there are exactly: 2 waypoints, 1 route (3 points), and 1 track (3 points).

The distinction matters because a route and a track can look identical on a map yet mean completely different things. A route is a plan — "I will go Start → Middle → End." A track is a record — "I actually went here, at these times, at these elevations." If you convert a recorded track into a planned route and send it back to a device, you have silently turned "what happened" into "what to do," which is how people end up navigating to a path they already walked.

Anatomy of a GPX file

Figure 2. The three GPX elements map to two GeoJSON geometry types.

2.1 What survives the trip (a fidelity table)

Not every attribute in a GPX makes it into every output format. Here is what to expect when you convert the three element types to GeoJSON, KML, and CSV:

GPX elementGeometry in GeoJSONName/desc preserved?Elevation/time preserved?In CSV?
<wpt>PointYes (name, desc, sym)If present (ele, time)Yes (one row)
<rte> + <rtept>LineStringYes (route name; point name in properties)If presentYes (one row per rtept)
<trk> + <trkseg> + <trkpt>LineString (or MultiLineString)Yes (track name; point name in properties)Yes (ele, time usually kept)Yes (one row per trkpt)

The headline: GeoJSON and KML both preserve names and (typically) elevation and time as properties or ExtendedData; CSV keeps only coordinates by default and is the place where rich attributes are most likely to be dropped unless you specifically request extra columns.

3. How GPX becomes GeoJSON

The de facto converter is togeojson (the Mapbox/Placemark library, also used inside many desktop tools). Its rules are simple and predictable:

So our sample — 2 waypoints, 1 route, 1 track — becomes a GeoJSON FeatureCollection with 4 features: 2 LineString + 2 Point, holding 8 coordinate pairs in total. The coordinates are already lon/lat, so the result plots immediately:

{
  "type": "FeatureCollection",
  "features": [
    { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-105.0, 40.0] } },
    { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-104.5, 40.5] } },
    { "type": "Feature", "geometry": { "type": "LineString", "coordinates": [[-106.0,39.0],[-105.5,39.5],[-105.0,40.0]] } },
    { "type": "Feature", "geometry": { "type": "LineString", "coordinates": [[-107.0,41.0],[-106.5,41.5],[-106.0,42.0]] } }
  ]
}

3.1 The coordinate-order trap

Notice the coordinate order carefully. GPX stores positions as lat="..." lon="..." attributes — latitude first, then longitude. GeoJSON (and everything that reads it — Leaflet, Mapbox, QGIS, Google Earth) expects longitude, latitude — longitude first, then latitude. A correct converter flips them. Ours did: the waypoint at lat="40.0" lon="-105.0" became [-105.0, 40.0].

If a converter forgets to flip, your point comes out as [40.0, -105.0] — a location in the Gulf of Guinea / eastern Atlantic rather than Colorado, USA. This is the GPX equivalent of the DWG coordinate-system trap: the geometry is fine, the interpretation is wrong, and the symptom is "all my points are in the ocean." If your converted GPX lands in the wrong place and the numbers look like valid small lon/lat (tens and hundreds, not millions), check the lat/lon flip before you check anything else.

3.2 GPX 1.0 vs GPX 1.1

GPX has two schema versions in the wild, and knowing which you have changes how you parse it:

For conversion purposes the differences rarely matter for geometry — both store lat/lon the same way — but they matter for metadata. A 1.0 file's links and names live in different elements than a 1.1 file's, so a converter that only understands 1.1 can silently drop a 1.0 file's names. Modern tools (togeojson, GDAL) handle both, but if you are writing your own parser, branch on the namespace in the root <gpx> element.

3.3 Elevation and time

GPX points frequently carry <ele> (elevation in metres) and <time> (ISO 8601 UTC timestamp). These are what make a track a record rather than just a line. Good converters preserve them:

If your analysis depends on when or how high a point was recorded (speed from time deltas, slope from elevation deltas), make sure the target format and converter keep those fields, or pull them explicitly.

3.4 Multiple track segments

A single <trk> can contain several <trkseg> segments — for example, when a device lost signal and resumed. The correct GeoJSON representation is a MultiLineString (one LineString per segment) or, in looser converters, several LineString features. Our sample has one segment, so it is a single LineString, but be aware that a track with gaps should not become one continuous line with a straight "jump" across the gap. Confirm your converter emits a MultiLineString (or separate features) when segments are present; otherwise a straight line will falsely connect two disconnected pieces of your journey.

4. Measured output sizes (one real 769-byte GPX)

I converted the same 769-byte sample to all three targets and recorded exact sizes.

SourceFormatOutput sizeFeatures
simple.gpx (769 B)GeoJSON1,365 B4 (2 LineString + 2 Point)
simple.gpx (769 B)KML1,627 B4 Placemarks
simple.gpx (769 B)CSV108 B4 rows (lon, lat)

Output size per format

Figure 3. Exact byte counts for one GPX exported three ways.

Two things are worth knowing:

5. Step-by-step: convert GPX to each format

Route A — in the browser (no install, no upload)

Open the GPX to GeoJSON, GPX to KML, or GPX to CSV tool, drop your .gpx, and click Convert. The interface shows the loaded file, the source/target selectors, and the finished download.

The converter in action

Figure 4. The geoo.app converter with the real GPX loaded.

After conversion the download is ready:

The conversion result

Figure 5. The converted GPX output, ready to download — produced entirely in the browser.

Because the conversion runs in your browser via WebAssembly, your GPX never leaves your machine — useful when the file contains a client's survey points or a private route.

Route B — ogr2ogr (desktop)

GDAL reads GPX directly, including its layered structure (it exposes waypoints, routes, and tracks as separate layers):

# GPX -> GeoJSON (one layer at a time; "tracks", "routes", or "waypoints")
ogr2ogr -f GeoJSON -sql "SELECT * FROM tracks" tracks.geojson simple.gpx
ogr2ogr -f GeoJSON -sql "SELECT * FROM waypoints" waypoints.geojson simple.gpx

If you omit the SQL, GDAL converts the first layer it finds; the -sql form lets you pick exactly which elements become features. This is the right tool when you need only the tracks, or only the waypoints, from a mixed file.

Route C — togeojson in Node

const { gpx } = require("@tmcw/togeojson");
const { DOMParser } = require("@xmldom/xmldom");
const fs = require("fs");

const xml = new DOMParser().parseFromString(
  fs.readFileSync("simple.gpx", "utf8")
);
const geojson = gpx(xml);
console.log(geojson.features.length); // 4

5.1 Batch-converting a folder of GPX files

When you have dozens of tracks from a season of fieldwork, convert them all at once with a shell loop:

mkdir -p geojson_out
for f in *.gpx; do
  ogr2ogr -f GeoJSON "geojson_out/${f%.gpx}.geojson" "$f"
done

Each file becomes its own GeoJSON. If you would rather have one combined file, see the next section.

5.2 Combining multiple GPX into one GeoJSON

To merge many tracks into a single FeatureCollection (handy for showing a whole season on one map), concatenate after conversion:

const fs = require("fs");
const files = fs.readdirSync("geojson_out").filter(f => f.endsWith(".geojson"));
const features = files.flatMap(f =>
  JSON.parse(fs.readFileSync(`geojson_out/${f}`)).features
);
fs.writeFileSync("all_tracks.geojson",
  JSON.stringify({ type: "FeatureCollection", features }));

The browser route on geoo.app handles one file at a time, so for bulk merges the ogr2ogr/Node path above is the more practical choice.

6. The CSV you get

A GPX-to-CSV export keeps the essentials: one row per point, with longitude and latitude columns (and usually name/elevation if present). For our sample the CSV is just:

longitude,latitude
-105.0,40.0
-104.5,40.5
-106.0,39.0
-105.5,39.5
-105.0,40.0
-107.0,41.0
-106.5,41.5
-106.0,42.0

That is the format spreadsheets, pandas, and most plotting tools want. If you only need to map or analyse the vertices, stop here — CSV is the smallest and most portable.

6.1 Preserving more than coordinates in CSV

If you need elevation or time in the spreadsheet too, request (or post-process) extra columns. With ogr2ogr you can keep fields explicitly:

ogr2ogr -f CSV -select "ele,time,name" points.csv simple.gpx -sql "SELECT * FROM tracks"

This produces a CSV with ele, time, and name columns alongside the coordinates — useful when you want to compute speed (from time deltas) or slope (from ele deltas) without leaving the spreadsheet.

7. Which format should you ship?

Use caseFormatWhy
Web maps, Leaflet/Mapbox, APIsGeoJSONnative to JavaScript, keeps geometry + properties
Google Earth, sharingKMLdouble-click to open, familiar to non-GIS users
Spreadsheets, quick plotsCSVsmallest, no markup, one row per point
Preserving device structurekeep GPXit is the only one that separates tracks/routes/waypoints

A practical pattern: keep the original GPX as your source of truth (it preserves track vs route vs waypoint, plus time and elevation), and derive GeoJSON/KML/CSV from it depending on who needs the file. You avoid re-extracting from the device, and you never lose the distinction between where you went and where you meant to go.

8. Caveats you should expect

8.1 GPX extensions

Both GPX 1.1 files and many vendors embed extra data in an <extensions> element — heart rate, cadence, temperature, course, speed, and more (often under a gpxdata or vendor namespace). Standard converters usually ignore extensions, so if your analysis needs heart rate or speed, either use a tool that reads the specific namespace or parse <extensions> yourself after conversion. This is the main place where "my GPX has it but my GeoJSON doesn't" confusion comes from.

9. Frequently asked questions

Is GPX already in WGS84? Almost always yes — GPX specifies latitude/longitude in decimal degrees. That is why it plots immediately, unlike CAD formats that live in projected metres.

Why does my GPX have no geometry after conversion? Usually a coordinate-order or namespace issue. Make sure the converter handles the GPX 1.1 namespace and flips lat/lon to lon/lat. A 1.0 file parsed as 1.1 (or vice versa) can also drop elements.

Can I convert GPX without uploading it? On geoo.app, yes — the conversion runs in your browser via WebAssembly, so the file never leaves your machine.

Track or route — which should I record? Record a track when you want the path you actually travelled (with time and elevation); plan a route when you want the path you intend to follow. They look similar on a map but mean different things, and a converter treats them identically as lines.

Why are my points in the ocean? Almost certainly a lat/lon vs lon/lat flip (Section 3.1). GPX is lat-then-lon; GeoJSON and web maps are lon-then-lat.

Will I keep elevation and time? In GeoJSON/KML, usually yes (as properties/ExtendedData). In CSV, only if you request those columns.

Can I convert only the tracks and ignore the waypoints? Yes — ogr2ogr with -sql "SELECT * FROM tracks" does exactly that; most browser converters export everything and you filter afterwards.

GPX 1.0 or 1.1 — does it matter? For geometry, barely. For metadata (names, links), yes; branch on the namespace if you parse it yourself.

How do I merge many GPX files? Convert each to GeoJSON, then concatenate their features into one FeatureCollection (Section 5.2), or use ogr2ogr with a VRT that lists all inputs.

Is GPX good for sharing with non-GIS friends? KML is friendlier for that (double-click opens in Google Earth); keep the GPX as your master and derive KML for sharing.

10. A short quality checklist before you publish

  1. Open the converted GeoJSON next to the original GPX in a map viewer. Do the lines and points overlap?
  2. Check the coordinate order. Are values in longitude, latitude (lon first)? If points are in the ocean, you have a lat/lon flip.
  3. Confirm geometry types. Did 2 waypoints become 2 Points and 1 route + 1 track become 2 LineStrings?
  4. If elevation/time matter, open the properties and confirm ele/time survived.
  5. For tracks with gaps, confirm multiple segments became a MultiLineString, not one continuous line.
  6. If sharing, derive KML from the GeoJSON; if analysing, derive CSV and request ele/time columns as needed.

11. Recap

A GPX file is three things at once: waypoints (points), routes (planned lines), and tracks (recorded lines). The conversion to GeoJSON is mostly a matter of mapping those three elements to Point and LineString features, flipping lat/lon to lon/lat, and deciding which attributes (name, elevation, time) you want to keep. On our real 769-byte sample, that produced 4 GeoJSON features (2 lines + 2 points, 8 coordinates) weighing 1,365 B, a 1,627 B KML, and a 108 B CSV.

Keep the GPX as your master, derive the rest as needed, watch the lat/lon flip, and you will never lose the distinction between where you went and where you meant to go.

For the CAD side of the same "convert my field file" problem, the DWG to GIS guide covers DWG, KML and Shapefile. And if you are weighing container formats in general, the KML vs KMZ and DWG vs DXF comparison measures those trade-offs directly.