Ad Space
Point A
Point B
Distance

Ad Space

How to Calculate Distance Between Coordinates

Because the Earth is (approximately) a sphere, the shortest path between two points on its surface isn't a straight line in the ordinary sense — it's a great-circle arc, the curved path a plane would fly along the surface of a globe. The Haversine formula computes exactly that great-circle distance from two points' latitude and longitude.

$$a = \sin^2\left(\frac{\Delta\phi}{2}\right) + \cos\phi_1 \cos\phi_2 \sin^2\left(\frac{\Delta\lambda}{2}\right)$$

$$c = 2 \cdot \text{atan2}\left(\sqrt{a}, \sqrt{1-a}\right) \qquad d = R \cdot c$$

φ1, φ2: latitude of point 1 and point 2, in radians.

Δφ: the difference in latitude between the two points, in radians.

Δλ: the difference in longitude between the two points, in radians.

R: Earth's mean radius — 6,371 km, or 3,959 miles.

d: the great-circle distance between the two points.

Worked Example

Using the calculator's own defaults — New York City (40.7128° N, 74.0060° W) and London (51.5074° N, 0.1278° W) — the Haversine formula gives a great-circle distance of roughly 5,570 kilometers, or about 3,460 miles. That's the true straight-line distance along the Earth's curved surface, noticeably shorter than any actual transatlantic flight path, which has to account for wind patterns, air traffic routing, and other real-world constraints.

Why Latitude and Longitude Need Converting to Radians

Latitude and longitude are naturally expressed in degrees, but the trigonometric functions (sine, cosine) used inside the Haversine formula expect their input in radians, the mathematically natural angular unit. Skipping this conversion — plugging degree values directly into sine and cosine — is the single most common implementation bug in a from-scratch Haversine calculation, and it produces wildly wrong distances rather than a small rounding error, since degrees and radians differ by a factor of roughly 57.3.

A Brief History of the Haversine Formula

The term "haversine" (half a versine, an older trigonometric function largely obsolete today) was coined by mathematician James Inman in the 1830s, developed for navigational distance calculations at sea. The formula's particular numerical form is valued for being well-conditioned even for very small distances — some alternative spherical-distance formulas lose precision due to floating-point rounding when two points are close together, a problem the haversine form largely avoids, which is part of why it remains the standard choice for coordinate-distance calculations in software today, nearly two centuries later.

Common Lat/Long Distance Mistakes

Forgetting the degrees-to-radians conversion, as noted above, is the most common error and produces a nonsensical result rather than a subtly wrong one. Swapping latitude and longitude — entering a location's longitude into the latitude field or vice versa — is a close second, since both are just decimal numbers with no built-in way to tell them apart; double-check that latitude (north/south, range -90 to 90) and longitude (east/west, range -180 to 180) are each in the correct field. Expecting the result to match a driving or flight distance is a conceptual mistake covered in the FAQ below — Haversine always gives the straight-line great-circle distance, not a routed travel distance.

Lat/Long Distance Terms You Should Know

Great-Circle Distance — the shortest path between two points along the surface of a sphere, following the arc of a circle whose center passes through the sphere's center.

Latitude — a coordinate measuring position north or south of the equator, from -90° (South Pole) to +90° (North Pole).

Longitude — a coordinate measuring position east or west of the Prime Meridian, from -180° to +180°.

Radian — the natural unit of angle measurement used in trigonometry, where a full circle equals 2π radians instead of 360 degrees.

This calculator treats the Earth as a perfect sphere, which is accurate to within about 0.5% for most practical purposes. Survey-grade or aviation applications requiring higher precision typically use an ellipsoidal formula such as Vincenty's instead.

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 — the shortest path along the Earth's curved surface, as opposed to a straight line through the Earth's interior. It's the standard method for distance-between-coordinates calculations.

How accurate is a Haversine distance calculation?

Very close for most purposes — typically within about 0.5% of the true distance. The small error comes from treating the Earth as a perfect sphere, when it's actually a slightly flattened spheroid (an oblate ellipsoid). For survey-grade precision, a more complex ellipsoidal formula like Vincenty's would be used instead.

Does this give the driving distance between two places?

No. This calculates straight-line, great-circle distance — as the crow flies — not a route along roads. Actual travel distance by car, on foot, or by any path that has to go around obstacles will always be longer than the great-circle distance.

Ad Space