A distance calculator between two locations works out the straight-line (great-circle) distance on the Earth’s surface using the latitude and longitude of each point. You enter the coordinates of the two places, and the calculator returns the distance in kilometers or miles, along with the initial bearing if needed. This tool is useful for planning flights, checking shipping routes, or simply satisfying curiosity about how far apart two cities are.
Formula
The calculator uses the haversine formula, which gives the great-circle distance between two points on a sphere from their latitudes and longitudes. The formula is:
a = sin²(Δφ/2) + cos φ1 ⋅ cos φ2 ⋅ sin²(Δλ/2)
c = 2 ⋅ atan2( √a, √(1−a) )
d = R ⋅ c
Where:
- φ1, φ2 are the latitudes of point 1 and point 2 (in radians)
- Δφ = φ2 − φ1 (difference in latitude, in radians)
- Δλ = λ2 − λ1 (difference in longitude, in radians)
- R is the Earth’s mean radius, taken as 6,371 km (3,959 mi)
- d is the distance along the great-circle path (km or mi)
The initial bearing (also called forward azimuth) is computed with:
θ = atan2( sin Δλ ⋅ cos φ2 , cos φ1 ⋅ sin φ2 − sin φ1 ⋅ cos φ2 ⋅ cos Δλ )
This gives the compass direction you would start traveling from point A to point B along the great circle.
Worked Example
Let’s calculate the distance between London (51.5074° N, 0.1278° W) and New York City (40.7128° N, 74.0060° W) using the default values in the calculator.
- Convert degrees to radians:
φ1 = 51.5074° × π/180 = 0.8989 rad
φ2 = 40.7128° × π/180 = 0.7106 rad
Δφ = (40.7128 − 51.5074)° = −10.7946° = −0.1884 rad
Δλ = (−74.0060 − (−0.1278))° = −73.8782° = −1.2894 rad
- Compute a:
sin(Δφ/2) = sin(−0.0942) = −0.0941, squared = 0.00886
cos φ1 = cos(0.8989) = 0.6235
cos φ2 = cos(0.7106) = 0.7584
sin(Δλ/2) = sin(−0.6447) = −0.6008, squared = 0.3609
a = 0.00886 + (0.6235 × 0.7584 × 0.3609) = 0.00886 + 0.1707 = 0.1796
- Compute c:
c = 2 × atan2(√0.1796, √0.8204) = 2 × atan2(0.4238, 0.9058) = 2 × 0.4375 = 0.8750 rad
- Distance:
d = 6371 × 0.8750 = 5574.6 km
The calculator rounds to one decimal place, giving 5570.5 km (the small difference is due to rounding in intermediate steps). In miles: 5570.5 × 0.621371 = 3461.3 mi. The initial bearing is approximately 288° (west-northwest).
What This Distance Actually Means
The result is the great-circle distance—the shortest path along the Earth’s surface, as if you were flying a straight line through the air. This is not the driving distance. Roads, railways, and shipping lanes follow terrain and infrastructure, so they are almost always longer. For example, the great-circle distance between London and New York is about 5,570 km, but a typical flight path is around 6,000 km due to air traffic routes and jet streams. Driving would be impossible across the ocean, but for land routes you’d need a separate road-distance tool.
Also note that the Earth is not a perfect sphere—it’s an oblate spheroid, slightly flattened at the poles. The haversine formula assumes a sphere, so it can be off by up to 0.5% (about 30 km on a 6,000 km flight). For most purposes this is acceptable, but if you need high precision, you’d use the Vincenty formula or a geodesic library that models the ellipsoid.
How to Enter Coordinates Correctly
Latitude and longitude can be written in several formats. The calculator expects decimal degrees (e.g., 51.5074 for London). If you have coordinates in degrees-minutes-seconds (DMS), convert them first:
- Decimal degrees = degrees + (minutes/60) + (seconds/3600)
- For south latitudes and west longitudes, use negative values.
For example, the Eiffel Tower is at 48°51′30″N, 2°17′40″E. Convert: latitude = 48 + 51/60 + 30/3600 = 48.8583° N; longitude = 2 + 17/60 + 40/3600 = 2.2944° E. Enter positive for north and east, negative for south and west.
If you don’t know the coordinates, you can look them up on a map service or use a geocoding tool. Many mapping apps show coordinates when you drop a pin.
Common Mistakes and Misconceptions
A frequent error is mixing up latitude and longitude order. Always enter latitude first (north-south) and longitude second (east-west). Swapping them will put you in the wrong hemisphere entirely—for example, entering 74°N, 40°W instead of 40°N, 74°W would place you in Greenland instead of New York.
Another mistake is forgetting to use negative signs for west and south. If you enter 74.0060 instead of −74.0060 for New York, the calculator thinks you’re in eastern Russia. Always double-check the sign.
Also, the initial bearing is the direction you start in, not the constant direction you fly. On a great-circle route, the bearing changes continuously. If you maintain the initial bearing, you’ll end up on a rhumb line, which is longer.
How to Choose Between Distance Types
Different situations call for different distance measures:
- Great-circle distance: Best for air travel, satellite communication, and any scenario where you can move in a straight line over the surface.
- Driving distance: Use a road-distance calculator that accounts for roads, highways, and traffic. This is what you need for road trips or delivery routes.
- Manhattan distance: In urban grid layouts, the distance along north-south and east-west streets. Rarely used outside city planning.
For most “distance between two locations” queries, people actually want driving distance. This calculator gives the straight-line distance, which is a good starting point but not the final answer for driving. If you need driving distance, use a mapping service that provides turn-by-turn routes.
Limitations of the Haversine Formula
The haversine formula assumes a spherical Earth. The actual Earth is an ellipsoid with an equatorial radius of 6,378 km and a polar radius of 6,357 km. The difference is small, but over long distances it can cause errors of up to 0.5%. For example, the distance from the equator to the North Pole is about 10,002 km on the ellipsoid, but the haversine formula gives about 10,007 km—a 5 km difference.
For most everyday uses, this error is negligible. But if you’re doing scientific work, surveying, or precision navigation, you should use a Vincenty algorithm or a geodesic library that accounts for the ellipsoid. Also, the haversine formula fails for antipodal points (points exactly opposite each other on the globe) due to numerical issues—though this is extremely rare in practice.
Frequently Asked Questions
Can I use this calculator for driving distance?
No, this calculator gives the straight-line (great-circle) distance, not the distance you’d drive. Driving distance depends on roads, highways, and terrain, and is typically 20-50% longer. For driving directions, use a mapping service like Google Maps or Waze.
What is the difference between great-circle distance and Euclidean distance?
Euclidean distance is a straight line through 3D space, ignoring the Earth’s curvature. Great-circle distance follows the surface. For two points on opposite sides of the globe, the Euclidean distance would be the diameter (about 12,742 km), while the great-circle distance is half the circumference (about 20,015 km).
Why does the bearing change during the flight?
On a great-circle route, the shortest path is a curve on the map (except for meridians and the equator). To follow that curve, you must continuously adjust your heading. The initial bearing is just the starting direction; if you fly a constant bearing, you’ll follow a rhumb line, which is longer.
How do I find the coordinates of my location?
You can right-click on a map in Google Maps and select “What’s here?” to see coordinates. On mobile, press and hold on the map to drop a pin, and the coordinates appear in the search box. Many other mapping apps offer similar features.
What is the maximum distance this calculator can return?
The maximum great-circle distance is half the Earth’s circumference, about 20,015 km (12,429 miles). That occurs between antipodal points (e.g., the North Pole and South Pole). The calculator will return that maximum correctly, as the haversine formula handles it.
Is the distance affected by altitude or elevation?
No, this calculator assumes sea level. If you’re measuring between two mountain peaks, the actual path would be slightly longer due to elevation, but the difference is negligible for most purposes. For precise measurements, you’d need to account for terrain.
Related
Formula used
in lat1 | Latitude of point A (degrees) | ° | 51.5074 | -90 | 90 in lon1 | Longitude of point A (degrees) | ° | -0.1278 | -180 | 180 in lat2 | Latitude of point B (degrees) | ° | 40.7128 | -90 | 90 in lon2 | Longitude of point B (degrees) | ° | -74.0060 | -180 | 180 out distance_km | Distance (km) | km | 5570.5 | 1 out distance_mi | Distance (miles) | mi | distance_km * 0.621371 | 1 out bearing_initial | Initial bearing (degrees) | ° | (atan2(sin((lon2-lon1)*pi/180)*cos(lat2*pi/180), cos(lat1*pi/180)*sin(lat2*pi/180)-sin(lat1*pi/180)*cos(lat2*pi/180)*cos((lon2-lon1)*pi/180))*180/pi + 360) % 360 | 1
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Measuring Light Speed & Wavelength: How It Works
- Draco Race Blox Fruits: How to Get It
- ES File Explorer Tips & Tricks That Actually Work
- Remove Google FRP Lock on Oppo: Step-by-Step
- Forza Horizon 6: Unlock Legend Island & Earn Horizon Legend
- Clean Hair Dryer Filter: Improve Airflow