Distance Between Coordinates
With latitude 1 40.7128 degrees, longitude 1 -74.006 degrees, latitude 2 51.5074 degrees, longitude 2 -0.1278 degrees, distance between coordinates comes to 3,461.2 mi — straight-line distance. It is reached in 6 steps, the last of which is kilometers * 0.621371192237334, and each one is printed on the page with its numbers filled in. The formula is the one published by Wolfram MathWorld, not an approximation fitted to it.
Great-circle distance between two latitude and longitude pairs, in miles, kilometres and nautical miles, with the initial bearing.
By Alex Seote, Built and maintains Rule Calculator · Formula and sources checked · How we check
Latitude 1 40.713 degrees, Longitude 1 -74.006 degrees, Latitude 2 51.507 degrees, Longitude 2 -0.128 degrees
3,461.2 mi
Straight-line distance for the example below. Editing a field recomputes the calculator below; this figure holds the answer the page was loaded with.
It is written into the HTML rather than drawn by a script, so a search engine reading this page without running JavaScript still finds an answer.
- Haversine of the central angle
pow(sin(dphi / 2), 2) + cos(phi1) * cos(phi2) * pow(sin(dlambda / 2), 2)0.179- Central angle
2 * asin(sqrt(min(1, h))) * 180 / pi50.094 °- Kilometres
2 * 6371.0088 * asin(sqrt(min(1, h)))5,570.23 km- Miles
kilometers * 0.6213711922373343,461.18 mi- Nautical miles
kilometers / 1.8523,007.684 nmi- Initial bearing
51.213 °
Worked example
New York to London is 3,461 miles in a straight line over the surface — 5,570 km, or 3,008 nautical miles. The initial bearing is 51 degrees, which is northeast: the shortest path bends north over Newfoundland rather than running due east, and that is why the flight does.
How to work it out yourself
- 1.Enter both positions in decimal degrees. A phone map gives them in that form; degrees and minutes need converting first.
- 2.Watch the signs. South latitudes and west longitudes are negative, and a missing minus sign is the one error that produces a confidently wrong answer.
- 3.Read the bearing as a compass heading from the first point. It changes along the route — a great circle is not a constant heading.
The formula
- Haversine of the central angle
pow(sin(dphi / 2), 2) + cos(phi1) * cos(phi2) * pow(sin(dlambda / 2), 2) - Central angle
2 * asin(sqrt(min(1, h))) * 180 / pi - Kilometres
2 * 6371.0088 * asin(sqrt(min(1, h))) - Miles
kilometers * 0.621371192237334 - Nautical miles
kilometers / 1.852 - Initial bearing
Source: Wolfram MathWorld — great circle, NOAA National Geodetic Survey — inverse geodetic computation
Questions people actually ask
- Is this the driving distance?
- No. It is the shortest path over the surface of the earth, which is what an aircraft approximates and what no road does. Driving distance is typically 15 to 40% longer depending on terrain, and there is no formula for it: it needs a road network, not geometry.
- Why is the shortest route not a straight line on the map?
- Because the map is flat and the earth is not. A Mercator projection stretches the high latitudes badly, so the genuinely shortest path — a great circle — appears as a curve arcing toward the pole. New York to London leaves on a bearing of 51 degrees, well north of due east, for exactly that reason.
- What is the haversine formula for?
- Numerical stability on short distances. The spherical law of cosines gives the same answer in theory, but for two points a few hundred metres apart the central angle is tiny, its cosine is within a rounding error of 1, and the subtraction loses most of the significant digits. The haversine keeps the half-angle sine instead, which stays well-conditioned.
- How accurate is a spherical earth?
- Within about 0.5% anywhere on the planet. The earth is an oblate spheroid — about 21 km wider across the equator than pole to pole — so a spherical calculation is short on some paths and long on others. Vincenty’s method on the WGS 84 ellipsoid closes that gap to millimetres and is what a surveyor uses; for anything short of surveying, the half-percent is well below the error in the coordinates themselves.
- What is a nautical mile?
- Exactly 1,852 metres, and it was defined as one minute of arc along a meridian — which is why the central angle line above, multiplied by 60, is almost exactly the nautical miles. It is the unit air and sea navigation still use, because it turns a distance into an angle without arithmetic.
Related
- Distance Formula CalculatorDistance between two points in the plane or in space, with the midpoint and the slope, and every step of the square root shown.
- Speed & Pace CalculatorAverage speed and running pace from a distance and a time, in both imperial and metric.
- Fuel Cost CalculatorWhat a trip costs in fuel, from its distance, the mileage the vehicle really gets and the pump price — with the cost per mile to compare on.
- Diagonal & Rafter Length CalculatorHypotenuse of a right triangle in feet and inches — brace lengths, rafter runs, and squaring a layout.
- Circle CalculatorArea, circumference and radius of a circle from its diameter — in square feet and square inches.
- Tank & Cylinder Volume CalculatorVolume of a cylinder in cubic feet, US gallons and litres — round tanks, pools, culverts and post holes.
Put this calculator on your site
Free, no attribution required beyond the link.
<iframe src="https://rulecalculators.com/embed/great-circle-distance" width="100%" height="420" style="border:1px solid #e7e4de;border-radius:12px" title="Distance Between Coordinates"></iframe>