Distance Between Coordinates: Haversine and Vincenty Explained
By FindMySum · Last reviewed
Given two points as latitude and longitude, how far apart are they? A distance between coordinates calculator answers that with spherical trigonometry or, more precisely, with geodesy on an ellipsoid. This one uses both: the Vincenty formula on the WGS-84 ellipsoid that GPS uses, and the simpler haversine formula on a sphere, and it gives the starting bearing and the midpoint too.
Entering coordinates
Latitude is the angle north or south of the equator, from −90° to 90°; longitude is the angle east or west of the Greenwich meridian, from −180° to 180°. In decimal degrees, south and west are negative: Ottawa is about 45.4215, −75.6972. In degrees, minutes and seconds, the same point is 45°25′17″N, 75°41′50″W. One degree has 60 minutes and one minute 60 seconds, so 45°25′17″ = 45 + 25/60 + 17/3600 = 45.4214°.
The haversine formula
Treating the Earth as a sphere of radius R, the distance d between two points is:
a = sin²(Δφ/2) + cos φ₁ × cos φ₂ × sin²(Δλ/2)
d = 2R × asin(√a)
where φ is latitude and λ longitude, in radians. The haversine form stays accurate for short distances, where the older law-of-cosines formula suffers from rounding. Using the international mean radius of 6,371.0088 km, the error from the sphere assumption is at most about 0.5%, largest on north–south routes at high latitudes.
Vincenty's formula on the ellipsoid
The Earth bulges at the equator: the WGS-84 ellipsoid has an equatorial radius of 6,378.137 km and a polar radius of about 6,356.752 km. Thaddeus Vincenty published an iterative method in 1975 that computes the shortest path on such an ellipsoid. It maps the points to an auxiliary sphere, iterates until the longitude difference settles (here to 10⁻¹² radians), then corrects for the ellipsoid's shape. It is accurate to well under a millimetre and is used by survey agencies including the US National Geodetic Survey.
For two points that are almost exactly opposite each other on the globe, the iteration can fail to settle. The calculator then falls back to haversine and says so.
A worked example
The calculator starts with Ottawa (45.4215, −75.6972) and Vancouver (49.2827, −123.1207).
- Vincenty on WGS-84: 3,549.200 km, or 2,205.4 statute miles and 1,916.4 nautical miles.
- Haversine on the sphere: 3,538.979 km, about 0.29% shorter.
- Initial bearing: 294.35°, west-northwest from true north. On arrival the bearing is 258.52°, because a great circle across Canada curves north of the straight line you would draw on a flat map.
- Midpoint: 49.854°N, 98.488°W, in southern Manitoba.
Bearings and midpoints
The initial bearing is the direction you would start out in along the shortest path, measured clockwise from true north. Along a great circle the bearing changes continuously, except when travelling along a meridian or the equator. To use it with a magnetic compass, adjust for the local magnetic declination, which in parts of Canada exceeds 15°.
The midpoint is the point halfway along the great circle on the sphere. It is useful for finding a fair meeting place or the centre of a route, and it is within metres of the ellipsoidal midpoint for most purposes.
Units
The calculator shows kilometres, statute miles (exactly 1,609.344 m) and nautical miles (exactly 1,852 m). Nautical miles are used in aviation and at sea because one nautical mile was originally one minute of latitude, which makes chart work easy.
Which result to use
For hiking, cycling routes, real-estate searches and most planning, the haversine figure is more than accurate enough: an error of a few hundred metres over thousands of kilometres rarely matters. Use the Vincenty figure when precision counts, such as checking survey data, comparing with GPS logs, setting property or drone boundaries, or calculating aviation and marine distances where small errors add up over long legs. Both are shown so you can see how much the Earth's shape matters for your two points.
What it doesn't do
The result is the distance over the Earth's surface at sea level. It doesn't account for elevation, terrain, roads, flight paths or shipping lanes, and it doesn't look up place names: enter coordinates copied from a map or GPS. For travel time, pair it with the speed, distance and time calculator.
More questions
How many kilometres is one degree of latitude?
About 111 km, varying slightly from roughly 110.6 km at the equator to 111.7 km near the poles because the Earth is flattened. One degree of longitude is 111.3 km at the equator and shrinks with the cosine of the latitude, reaching zero at the poles.
How precise should my coordinates be?
Each decimal place of a degree is about ten times finer. Four decimals locate a point to roughly 11 metres, five to about 1 metre and six to about 10 centimetres. Consumer GPS is typically accurate to a few metres, so more than six decimals adds nothing.
What is the difference between a great circle and a rhumb line?
A great circle is the shortest path between two points on a sphere, but its compass bearing changes along the way. A rhumb line keeps a constant bearing, which is easier to steer, but is longer except along the equator or a meridian. On a flat Mercator map the rhumb line looks straight and the great circle looks curved.
Does the datum matter?
For most purposes no: GPS, web maps and modern Canadian (NAD83) and US datums agree to within a metre or two. Old maps on NAD27 can differ by tens to hundreds of metres. If your coordinates come from an old survey, convert them to WGS-84 or NAD83 first.
Why do online maps show a curved line for flights?
Flat maps distort the globe. The shortest path between two cities is a great circle, which on most map projections looks like an arc bending toward the nearer pole. That is why a flight from Toronto to Tokyo passes over the Arctic.
Sources
This article explains how the calculator works and is general information, not financial, tax, legal or medical advice. Rules change; check the sources above or a qualified professional before you act.