Calculate great-circle distance between latitude and longitude points, including kilometers, miles, nautical miles, bearings, midpoint, and destination coordinates.
Related Calculators
- Polar Distance Calculator
- Central Angle Calculator
- Distance From Point to Plane Calculator
- Inverse Tan Calculator
- All Math and Numbers Calculators
Haversine Distance Formula
The following formula is used to calculate the Haversine Distance between two points on the surface of a sphere (often Earth).
d = 2 * r * arcsin(sqrt(sin^2((lat2-lat1)/2) + cos(lat1) * cos(lat2) * sin^2((lon2-lon1)/2)))
Variables:
- d is the Haversine distance between the two points (km or miles)
- r is the radius of the sphere (usually Earth’s radius, approx. 6371km or 3959 miles)
- lat1, lon1 are the first pointโs latitude and longitude, converted from entered degrees to radians for the formula
- lat2, lon2 are the second pointโs latitude and longitude, converted from entered degrees to radians for the formula
Convert coordinates to radians. Calculate a = sinยฒ((lat2 โ lat1)/2) + cos(lat1) ร cos(lat2) ร sinยฒ((lon2 โ lon1)/2). Clamp small floating-point excursions of a to the interval 0โ1. Take the arcsine of โa first, then multiply that angle by 2r. The calculator uses an equivalent stable vector calculation for the central angle. Earth is modeled as a sphere, so this is an approximation to an ellipsoidal surface distance.
What is a Haversine Distance?
Haversine Distance is a method of calculating the shortest distance between two points on the surface of a sphere, given their longitudes and latitudes. It is especially important in navigation and geography where accurate distance measurements between points on the Earth’s surface are required. The formula is derived from the haversine formula in trigonometry and takes into account the Earth’s curvature to give more accurate results than methods assuming a flat Earth.
How to Calculate Haversine Distance?
The following steps outline how to calculate the Haversine Distance:
- First, gather the values for the variables: r, lat1, lon1, lat2, lon2.
- Next, convert the latitude and longitude values from degrees to radians.
- Next, calculate the differences between the latitude and longitude values: dlat = lat2 – lat1 and dlon = lon2 – lon1.
- Next, calculate the square of the sine of half the differences: sin2_dlat = sin^2(dlat/2) and sin2_dlon = sin^2(dlon/2).
- Next, form a = sin2_dlat + cos(lat1) ร cos(lat2) ร sin2_dlon, using radian coordinates.
- Next, calculate the Haversine distance using d = 2 ร r ร arcsin(โa). The arcsine operates on โa before multiplying by 2r.
- Finally, calculate the Haversine Distance.
- After inserting the variables and calculating the result, check your answer with the calculator above.
Example Problem :
Use the following variables as an example problem to test your knowledge.
r = 6371 (Earth’s radius in km)
lat1 = 40 (latitude of the first point in degrees)
lon1 = -75 (longitude of the first point in degrees)
lat2 = 35 (latitude of the second point in degrees)
lon2 = -80 (longitude of the second point in degrees)
