Maps and geodesy
Distance and bearing between two coordinates
Geodesic distance, initial and final bearing and midpoint between two latitude/longitude points on the WGS84 ellipsoid, with the haversine great-circle result for comparison.
Runs in your browser. What you enter stays on this page and is not uploaded.
Showing the worked example. Results update as you type.
Result
Method and limits
Distances and bearings use Karney’s algorithms for geodesics on the WGS84 ellipsoid (a = 6,378,137 m, f = 1/298.257223563), through the GeographicLib JavaScript library. They are accurate to about 15 nanometres for any pair of points, including nearly antipodal ones where Vincenty’s iteration fails to converge. The initial bearing is the direction to set off in, clockwise from true north; the final bearing is the direction of travel on arrival, which differs because a geodesic is not a line of constant bearing. The midpoint is halfway along the geodesic.
For comparison, the haversine formula gives the great-circle distance on a sphere of mean radius R = 6,371.0088 km:
a = sin²(Δφ/2) + cos φ1 cos φ2 sin²(Δλ/2), d = 2R · asin(√a)
It is simple and fast but treats the Earth as round, so it can be off by up to about 0.5%.
Worked example (GeographicLib documentation): Wellington, New Zealand (41.32°S, 174.81°E) to Salamanca, Spain (40.96°N, 5.50°W) is 19,959,679.267 m with an initial bearing of 161.067669986° and a final bearing of 18.825195123°. The haversine formula gives 19,967.404 km, 7.7 km longer.
Limits
Distances are along the WGS84 ellipsoid at sea level; they ignore terrain, height above the ellipsoid and the route actually travelled. Bearings are true, not magnetic: subtract the local magnetic declination for a compass bearing.
References
- Karney, C. F. F. (2013). Algorithms for geodesics. Journal of Geodesy, 87, 43–55
- GeographicLib: geodesic routines and worked examples
- GeographicLib JavaScript library (geographiclib-geodesic 2.2.0, MIT licence)
- Karney, C. F. F. (2011). Test set for geodesics (GeodTest)
- Sinnott, R. W. (1984). Virtues of the haversine. Sky and Telescope, 68(2), 159
Related tools
- Coordinate converter: decimal degrees, DMS, UTM and MGRSConvert WGS84 coordinates between decimal degrees, degrees-minutes-seconds, degrees and decimal minutes, UTM and MGRS, with grid convergence and scale factor.
- Destination point from bearing and distanceFind where you arrive after travelling a distance on an initial bearing from a start point, on the WGS84 ellipsoid, with the final bearing and the spherical answer for comparison.
- Polygon area on the ellipsoid from coordinatesPaste latitude/longitude points, GeoJSON or WKT and get the area and perimeter of the polygon on the WGS84 ellipsoid, in km², hectares, acres and square miles.