Haversine Distance Calculator
Calculate the great-circle distance between two geographic coordinates using the Haversine formula. Includes bearing, midpoint, and travel time estimates.
Haversine Distance Calculator
Calculator
Adjust values & calculateEnter your values below. Every result is computed in your browser โ no data is sent to any server.
Formula: d = 2R x arcsin(sqrt(sin2(dLat/2) + cos(lat1) x cos(lat2) x sin2(dLon/2)))
Worked example โ 5,570.25 km (3,461.02 miles, 3,007.69 nautical miles)
Formula
d = 2R x arcsin(sqrt(sin2(dLat/2) + cos(lat1) x cos(lat2) x sin2(dLon/2)))
The Haversine formula finds the central angle between two points using their latitude and longitude differences, then multiplies by Earth's radius to get the arc length. The haversine function (sin squared of half angle) provides numerical stability for both small and large distances.
Worked Examples
Example 1: New York to London
Problem:Calculate the distance from New York (40.7128 N, 74.006 W) to London (51.5074 N, 0.1278 W).
Solution:dLat = 10.7946 deg, dLon = 73.8782 deg a = sin2(5.3973) + cos(40.71) x cos(51.51) x sin2(36.94) a = 0.00885 + 0.7580 x 0.6223 x 0.3612 = 0.1792 c = 2 x atan2(0.4233, 0.9060) = 0.8742 rad d = 6371 x 0.8742 = 5,570 km
Result:5,570.25 km (3,461.02 miles, 3,007.69 nautical miles)
Example 2: Short Distance
Problem:Calculate distance from Times Square (40.7580, -73.9855) to Central Park (40.7829, -73.9654).
Solution:dLat = 0.0249 deg, dLon = 0.0201 deg Very short distance, Haversine still accurate d = approximately 3.14 km
Result:Approximately 3.14 km (1.95 miles)
Frequently Asked Questions
What is the Haversine formula?
The Haversine formula calculates the great-circle distance between two points on a sphere given their latitude and longitude. It uses the haversine function (half of the versine), which is hav(theta) = sin2(theta/2). The formula accounts for the curvature of the Earth by working with angular distances. It is more numerically stable than the simpler spherical law of cosines for short distances, making it the preferred method for geographic distance calculations in navigation and mapping applications.
How accurate is the Haversine distance calculation?
The Haversine formula assumes a perfectly spherical Earth with a mean radius of 6,371 km. Since Earth is actually an oblate spheroid (slightly flattened at the poles), the Haversine formula can have errors up to about 0.3% compared to the more accurate Vincenty formula which uses the WGS84 ellipsoid. For most practical purposes including flight planning, shipping routes, and general navigation, the Haversine distance is sufficiently accurate. For surveying or precision mapping, the Vincenty method is preferred.
What is a great-circle distance?
A great-circle distance is the shortest distance between two points on the surface of a sphere, measured along the surface. It follows the path of a great circle, which is the intersection of the sphere with a plane that passes through the center of the sphere. On Earth, this is the shortest flight path between two cities. Great-circle routes can appear curved on flat Mercator projection maps even though they represent straight paths on the globe, which is why transatlantic flights often pass over Greenland or Iceland.
What is the initial bearing and why does it change along a great circle?
The initial bearing (also called forward azimuth) is the compass direction you face at the starting point when heading toward the destination along the great-circle path. Unlike a rhumb line (constant bearing), the bearing along a great circle changes continuously because you are following a curved path on a sphere. For example, a flight from New York to London starts heading northeast but gradually shifts to east and then southeast. The initial bearing is calculated using the atan2 function applied to the coordinates of both points.
What is the difference between a great-circle route and a rhumb line?
A great circle is the shortest surface path between two points, but its true bearing changes continuously along the way. A rhumb line, or loxodrome, holds a single constant compass bearing and plots as a straight line on a Mercator chart, which made it the practical choice before electronic navigation. The rhumb line is always the longer of the two, and the penalty grows with latitude and with east-west separation. On a North Atlantic crossing the rhumb line adds well over a hundred kilometres, which is why long-haul flights follow great-circle tracks instead.
How is the midpoint between two coordinates calculated?
The midpoint of a great-circle path is not the arithmetic average of the two latitudes and longitudes, because that average ignores the curvature of the sphere and the convergence of meridians. Instead the coordinates are converted to Cartesian components, Bx = cos(lat2) x cos(dLon) and By = cos(lat2) x sin(dLon), then the midpoint latitude comes from atan2 of the summed sine terms over the combined horizontal component. The error from naive averaging is small for nearby points but grows to many kilometres over intercontinental distances or near the poles.
Why is the distance also reported in nautical miles?
The nautical mile is defined as exactly 1,852 metres, chosen because it is very close to one minute of arc along a great circle on the Earth surface. That definition makes it uniquely convenient for navigation: a central angle of one degree corresponds to roughly 60 nautical miles, so a chart distance converts directly into an angular separation. Marine and aviation charts, airspeed in knots, and flight-planning software all work in nautical miles, so the converted value drops straight into a navigation log without further scaling.
How should I enter southern latitudes and western longitudes?
Coordinates must be entered as signed decimal degrees. Latitude runs from -90 to +90 with negative values south of the equator, and longitude runs from -180 to +180 with negative values west of the prime meridian. If your source gives degrees, minutes and seconds, convert first with decimal degrees = degrees + minutes/60 + seconds/3600, then apply the sign for the S or W hemisphere. Dropping a minus sign is the most common input error and typically places the point on the opposite side of the globe.
When does the spherical law of cosines fail where the Haversine formula does not?
The law of cosines recovers the central angle from arccos of a sum of products. For two points only a few metres apart that sum evaluates to a number extremely close to 1, and double-precision floating point cannot resolve the difference, so arccos returns a badly rounded angle and the distance collapses to zero or jumps erratically. The haversine formulation works with the sine squared of half the angular differences, which stay well away from that precision cliff, so it stays stable from a few metres up to nearly antipodal separations.
Why is the estimated driving distance longer than the great-circle distance?
Roads never follow the geodesic. The ratio of actual road distance to straight-line distance is called the circuity factor, and this tool applies a flat 1.3 multiplier as a rough allowance for road networks, terrain and detours. Real circuity varies widely: a dense street grid may sit near 1.2, while mountainous, coastal or island routes can exceed 2.0, and a great-circle path crossing open ocean has no road equivalent at all. Treat the drive figure as an order-of-magnitude sanity check, not a routing result.
References
Reviewed for accuracy by Manoj Kumar, Mathematics Educator ยท Editorial policy
Related Calculators
๐งฎDistance Between Coordinates Calculator
Calculate distance between coordinates with inputs, formulas, and instant results.
๐งฎDistance on MAP Calculator
Calculate distance on map with inputs, formulas, and instant results.
๐งฎGreat Circle Distance Calculator
Calculate great circle distance with inputs, formulas, and instant results.
๐งฎMAP Scale to Distance Calculator
Calculate map scale to distance with inputs, formulas, and instant results.
๐งฎStep Length to Distance Converter
Calculate step length to distance converter with inputs, formulas, and instant results.
๐งฎFeet to Meters Converter
Convert between feet, meters, yards, and miles for distance and height.
๐งฎMiles to Kilometers Converter
Convert distance between miles, kilometers, nautical miles, and meters.
๐งฎAstronomical Unit Calculator
Calculate astronomical unit with inputs, formulas, and instant results.