geoprimsField-grade geospatial math

Haversine distance (spherical)

The great-circle distance on a sphere by the haversine formula, with its error against the ellipsoidal geodesic shown.

Planning and education aid. Not for primary navigation. Full disclaimer

A published result changed on 2026-09-19: The geohash encoder, map tile for a point, tile bounds, H3 grid disk, and haversine distance are now stable, so their results no longer carry the EXPERIMENTAL_TOOL warning; the Web Mercator clamp and pentagon warnings moved to the first position. Each matches published worked examples (Wikipedia, the mercantile README, the Bing Maps Tile System, H3 C, and Rosetta Code) and agrees with a separately written library on 250 to 1,000 cases. No numbers changed. Changelog

Measures on a sphere, not on the ellipsoid the Earth actually is. Use the geodesic distance for anything you act on: it is exact on WGS 84, and this tool reports how far the sphere puts it wrong for your own two points. Karney (2013), the geodesic algorithm the geodesic tools use.

5,540.019km

The haversine distance is 5,540.019 km, 14,890 m (0.27%) shorter than the ellipsoidal geodesic.

Ellipsoidal distance
Difference
Difference (percent)
Provenance
Computed by
navigation.geodesic.haversine 1.0.1, core 0.1.0
Model
Haversine great circle on a sphere of radius R1; compared with Karney (2013) on WGS 84
Accuracy
Exact on the sphere. On the Earth the sphere itself is off by up to about 0.5%; the difference is reported
Notes
None
Cites
Moritz, H., International Association of Geodesy, Geodetic Reference System 1980 (mean radius R1 = (2a + b)/3); Karney, C. F. F., Journal of Geodesy, Algorithms for geodesics

Something look off?

Your values

Showing an example. Change anything.
More options 1
Run many at once from a CSV

Loading…

How we got thisFormula, worked example, sources, and proof

Model: Haversine great circle on a sphere of radius R1; compared with Karney (2013) on WGS 84

Show your work

  1. Half-chord squared

    h=sin2(Δφ/2)+cosφ1×cosφ2×sin2(Δλ/2)

    Δφ = 10.8287°, Δλ = 73.3238°, φ₁ = 40.6413°, φ₂ = 51.47° = 0.177421277

  2. Great-circle distance

    d=2×R×asin(h)

    2 × 6,371.009 km × asin(√0.177421277) = 5,540.019 km

The same steps an agent gets from the MCP server with explain: true.

Accuracy: Exact on the sphere. On the Earth the sphere itself is off by up to about 0.5%; the difference is reported

When to use this: Use this when you want the classic spherical distance, either because a specification calls for the haversine formula, because you are checking another system that uses it, or because you want to see how far the sphere is from the ellipsoid for your pair of points. The difference against the exact geodesic is reported beside the answer.

Limitations: A sphere is not the Earth: this can differ from the ellipsoidal distance by up to about half a percent, which is kilometers on a long leg, and the error depends on latitude and direction. Use the geodesic tool when the distance is the answer rather than the method. Course angles from a sphere carry the same approximation.

Worked example: JFK to Heathrow on the mean-radius sphere. Source: add-navigation-and-geometry scenario: about 5,540,019 m, 14,890 m (0.27%) shorter than the geodesic. It is golden test vector v001, and every build checks the tool still gives its answer within its tolerance.

You enter

Start latitude
40.6413 deg
End latitude
51.47 deg
Start longitude
-73.7781 deg
End longitude
-0.4543 deg

You get

Haversine distance
5,540.019 km
Ellipsoidal distance
5,554.909 km
Difference
14,890 m
Difference (percent)
0.27

Review: Not yet independently reviewed by a geodesist.

Last verified: 2026-09-18, when a maintainer last confirmed this tool's sources at the issuer. See the sources ledger.

Status: version 1.0.1, core 0.1.0. See this tool in the verification report.

Changes

Checked against: 20 golden test vectors (download the test vectors, each with its source and tolerance). See how results are checked and every source.

Sources

Terms

IUGG: International Union of Geodesy and Geophysics
The scientific union that adopted GRS 80 and the mean Earth radius R1. Source: Geodetic Reference System 1980
R1: IUGG mean Earth radius
The radius of a sphere the size of the Earth on average, (2a + b) ÷ 3 = 6,371,008.771 m for WGS 84. Spherical formulas use it when they treat the Earth as a ball. Source: Geodetic Reference System 1980