GPX Track Distance Calculator
A GPX track records your route as an ordered list of latitude and longitude points. The distance between any two points is the great-circle distance: the shortest path across the curved surface of the Earth. This calculator applies the haversine formula, the standard method for short track segments, using the WGS84 mean Earth radius of 6,371,008.8 metres. Enter the latitude and longitude of two track points to get the segment distance in metres, kilometres, and miles. Sum each consecutive segment to get a full track length.
Haversine distance formula
d-lat = lat2 - lat1 (radians)
d-lon = lon2 - lon1 (radians)
a = sin(d-lat/2)^2 + cos(lat1) * cos(lat2) * sin(d-lon/2)^2
c = 2 * atan2(sqrt(a), sqrt(1 - a))
distance = R * c
R is the Earth radius (default 6,371,008.8 m, the WGS84 mean). All angles convert from degrees to radians before the trigonometry. Initial bearing is the forward azimuth from point 1 to point 2.
GPX distance context
- Great-circle distance is the shortest path over the spherical surface, not the straight-line chord through the Earth.
- WGS84 is the geodetic datum that GPS receivers report positions in.
- Haversine error versus the true ellipsoidal geodesic is under about 0.5 percent and negligible for short segments.
- Sum the distance of each consecutive point pair to get a full GPX track length.
- Add elevation change as a separate 3D correction if you need slope distance.
GPX distance: frequently asked questions
What formula does this calculator use?
It uses the haversine formula, which computes the great-circle (shortest surface) distance between two points on a sphere from their latitude and longitude. The Earth is modeled as a sphere of mean radius 6,371,008.8 metres, the WGS84 mean radius. Haversine is the standard method for short GPX segment distances.
How accurate is the haversine distance?
Because the Earth is an oblate spheroid rather than a perfect sphere, haversine introduces an error of up to about 0.5 percent over long distances. For typical GPX track segments (tens to hundreds of metres) the error is negligible. For survey-grade geodesic distance over long baselines, use a Vincenty or geodesic ellipsoid solution instead.
What is the WGS84 mean Earth radius?
WGS84 is the reference ellipsoid used by GPS. Its semi-major axis is 6,378,137 m and its flattening is 1/298.257223563. The mean radius R1 = (2a + b)/3 is about 6,371,008.8 m. This single radius is the conventional value for spherical great-circle calculations.
Why total a whole GPX track by summing segments?
A GPX track is an ordered list of points. The total track distance is the sum of the great-circle distances between each consecutive pair of points. This calculator computes one segment; sum each consecutive pair across your track to get the full length.
Does this account for elevation change?
No. The haversine distance is the horizontal surface distance only. To include climb, compute the 3D distance as the square root of (horizontal distance squared plus elevation change squared) for each segment. This calculator reports the horizontal great-circle distance.
Official sources
- U.S. National Geospatial-Intelligence Agency: WGS84 coordinate systems.
- NOAA National Geodetic Survey: geodetic datums and tools.
Reviewed by the CalculatorHub team, edited by James Graham, 17 June 2026. See our methodology.