Sports

GPX Distance Calculator

Paste lat/lon waypoints to calculate total route distance using the haversine formula. Free for hikers, runners, and route planners.

Quick Answer

The haversine formula computes great-circle distance between latitude/longitude pairs. Paste waypoints (one per line as “lat, lon”) and get the cumulative distance along the route. Accurate within 0.5% for any hiking-scale distance.

Format: latitude, longitude per line. Decimal degrees only. Comma or space separated.

Total Route Distance
260.92 km
162.13 miles · across 4 waypoints
Total km
260.92
Total miles
162.13

Segment Distances

#From → Tokmmiles
137.7749, -122.419437.8044, -122.271213.438.34
237.8044, -122.271237.8716, -122.27277.474.64
337.8716, -122.272737.8651, -119.5383240.02149.14

About This Tool

The GPX Distance Calculator computes total distance along a route from a list of latitude/longitude waypoints using the haversine formula. It's the standard tool for trip planning when you have GPS coordinates from a topo map, mapping app, or GPX file. The haversine formula is accurate to within 0.5% for any hiking-scale distance, which is more than precise enough for trail planning, race courses, and route distance verification.

How the Haversine Formula Works

The haversine formula calculates the great-circle distance between two points on a sphere given their latitudes and longitudes. The formula: a = sin²(Δφ/2) + cos(φ₁) · cos(φ₂) · sin²(Δλ/2), then c = 2 · atan2(√a, √(1-a)), then distance = R · c, where R is Earth's radius (~6,371 km). It's named after the haversine function, half of (1 - cos(θ)). The formula handles the curvature of Earth's surface, which matters for distances above ~10 km. For hiking and running scales, it's essentially perfect.

Where to Get Coordinates

The fastest sources: Google Maps (right-click any point and click the lat/lon to copy), Gaia GPS or CalTopo (click points to display coordinates), OpenStreetMap (search any feature). For named landmarks, peakbagger.com and Wikipedia list precise coordinates. For race courses, organizers usually publish a GPX file you can decode using free GPX viewers. Most GPS devices export waypoints as decimal degrees by default.

Coordinate Formats

This tool accepts decimal degrees only — the standard format used by GPS devices and digital maps. Format: latitude (positive for North, negative for South), comma or space, longitude (positive for East, negative for West). Examples: 37.7749, -122.4194 (San Francisco) or 51.5074 -0.1278 (London). If you have degrees-minutes-seconds (37°46'30"N), convert to decimal first: degrees + minutes/60 + seconds/3600.

GPX vs. Trail Distance

The distance this tool calculates is the straight-line (great-circle) distance between consecutive waypoints. Real trail distance is longer because trails switchback, contour around obstacles, and follow terrain. Rule of thumb: real trail distance is 5-15% longer than waypoint-to-waypoint great-circle distance for typical terrain, more in steep switchback country (20-30% longer). For accurate trail planning, use waypoints spaced 0.5-1 mile apart along the actual trail path, not just at start/end/peak.

Use Cases

Trip planning: estimate total mileage from named waypoints on a topo map. Race verification: confirm advertised race distance from coursebook lat/lons. Route comparison: evaluate multiple route options between same start/end. Trail audit: cross-check GPS-recorded mileage against expected distances. Multi-day planning: divide total mileage into reasonable daily segments and compute distances between camps.

The Earth Isn't a Perfect Sphere

Earth is slightly oblate (squished at the poles), so the haversine formula has small errors compared to formulas that account for the ellipsoid (Vincenty's formula). For distances under 100 km, haversine error is under 0.05%. For 1,000 km routes, error is around 0.5%. For most outdoor sports applications, haversine is more than accurate enough. Vincenty's formula is used for surveying and aviation where higher precision matters.

Combine With Other Trail Tools

Pair this with our elevation gain calculator, our hiking time calculator, our trail running pace calculator, and our summit time calculator.

Frequently Asked Questions

What is the haversine formula?
The haversine formula computes the great-circle distance between two points on a sphere from their latitudes and longitudes. It's the standard formula for distance calculation between GPS coordinates and is accurate to within 0.5% for distances under 1,000 km, which covers virtually all hiking, running, and trail planning use cases. It assumes a perfectly spherical Earth (we're slightly oblate) but the error is negligible for outdoor sports.
Why doesn't this match my GPS device's distance?
GPS devices record dozens of points per minute, capturing every wiggle of your trail. This calculator computes straight-line (great-circle) distance between waypoints. So if your waypoints are spaced 1 km apart, your GPS distance will be slightly longer because it captures the actual switchbacks. For accurate trail distances, use closer waypoint spacing or accept the calculator's straight-line estimate as a minimum.
What format should I use for coordinates?
Decimal degrees (e.g., 37.7749, -122.4194) is the standard format. Each line should be 'latitude, longitude' or 'latitude longitude'. Negative numbers for south latitudes and west longitudes (Western Hemisphere). Don't use degrees-minutes-seconds (37°46'30"N) — convert to decimal first. Most GPS devices and mapping apps export in decimal degrees by default.
Where do I get lat/lon coordinates?
Sources: Google Maps (right-click for coordinates), Gaia GPS, CalTopo, AllTrails, OpenStreetMap, USGS topo maps with grid overlays, FATMAP. Most apps let you click a point and copy the lat/lon. For trip planning, identify named features (peaks, trail junctions, lakes) and look up their coordinates from any topo source.
Is GPX distance the same as trail distance?
Close but not identical. GPS-recorded trail distance includes every step you took, including off-trail wandering and GPS noise. The straight-line distance between waypoints from this calculator is shorter than actual trail mileage by 5-15% on switchback-heavy terrain. For race courses or planning, use named waypoint spacing of 0.5-1 mile for accurate results.