Distance Calculator
2D Distance Calculator
- Working
- √((4 − 1)² + (5 − 1)²) = √(9 + 16)
- Midpoint
- (2.5, 3)
- Slope
- 1.33333333
3D Distance Calculator
- Working
- √(1 + 1 + 1)
- Midpoint
- (1.5, 1.5, 1.5)
Distance Based on Latitude and Longitude
Enter coordinates as decimal degrees (north and east positive) or as degrees, minutes and seconds.
- Great-circle distance (haversine)
- 199.831 km (124.169 miles)
- Nautical miles
- 108.018
- Point 1 (decimal)
- 38.8976, -77.0366
- Point 2 (decimal)
- 39.9496, -75.1503
Straight-line distance over the Earth's surface, not road or flight-path distance.
This distance calculator finds the straight-line distance between two points on a plane or in space, and the great-circle distance between two places given their latitude and longitude.
The calculators above measure distance in two different settings. On a flat plane or in ordinary three-dimensional space, the shortest path between two points is a straight line and its length comes from the Pythagorean theorem. On the curved surface of the Earth, the shortest path follows a great circle, and the calculation needs spherical or ellipsoidal geometry instead.
Distance in a coordinate system
In a two-dimensional Cartesian coordinate system each point is written (x, y). The horizontal gap between two points is x₂ − x₁ and the vertical gap is y₂ − y₁. These two gaps are the legs of a right triangle whose hypotenuse is the straight line joining the points, so the Pythagorean theorem gives its length: the square root of the sum of the squared gaps. For (1, 1) and (4, 5) the gaps are 3 and 4, and the distance is √(9 + 16) = 5.
The order of the points does not matter because each gap is squared, which removes any negative sign. The same reasoning extends to three dimensions: the gap in z adds a third squared term, so the distance between (1, 1, 1) and (2, 2, 2) is √(1 + 1 + 1) = √3 ≈ 1.732. In fact the formula works in any number of dimensions, which is why data scientists use it, under the name Euclidean distance, to measure how similar two records with many numeric features are.
The Euclidean distance is the length of a straight path. In a city laid out on a grid you often cannot travel diagonally, and the useful measure is the taxicab or Manhattan distance, |x₂ − x₁| + |y₂ − y₁|, which for the example points is 3 + 4 = 7 blocks rather than 5.
d = √((x₂ − x₁)² + (y₂ − y₁)²)
- (x₁, y₁)
- the first point
- (x₂, y₂)
- the second point
In three dimensions add (z₂ − z₁)² under the square root.
Distance between two points on Earth's surface
Locations on Earth are given by latitude, the angle north or south of the equator, and longitude, the angle east or west of the prime meridian through Greenwich. Because the Earth is round, the shortest route between two places is an arc of a great circle, a circle whose center is the center of the Earth. Airline routes between distant cities look curved on flat maps for exactly this reason.
If the Earth is treated as a perfect sphere, the haversine formula gives the great-circle distance. With latitudes φ and longitudes λ in radians, it computes a = sin²(Δφ/2) + cos φ₁ cos φ₂ sin²(Δλ/2), then the central angle c = 2 asin(√a), and finally the distance d = R c, where R is the Earth's radius. This calculator uses the mean radius of 6,371.0088 km recommended by the International Union of Geodesy and Geophysics. The haversine form is preferred over the simpler spherical law of cosines because it stays accurate for points that are very close together.
The Earth is actually slightly flattened, about 21 km shorter from pole to pole than across the equator, so spherical results can be off by up to about 0.5%. For better accuracy, the main result uses Vincenty's inverse formula on the WGS-84 ellipsoid, the same reference shape used by GPS. It solves iteratively for the geodesic distance and is accurate to well under a millimeter for most pairs of points, though it can fail to converge for points almost exactly on opposite sides of the planet.
The default example measures from 38.8976° N, 77.0366° W in Washington, D.C., to 39.9496° N, 75.1503° W in Philadelphia, roughly 200 km. Coordinates in degrees, minutes and seconds convert to decimal degrees with degrees + minutes ÷ 60 + seconds ÷ 3,600, made negative for south latitudes and west longitudes.
Frequently asked questions
What is the distance formula?
d = √((x₂ − x₁)² + (y₂ − y₁)²). It is the Pythagorean theorem applied to the horizontal and vertical gaps between the points.
How do I find the distance between two cities?
Enter each city's latitude and longitude in the third calculator. It returns the straight-line distance over the Earth's surface, which is shorter than the driving distance.
What is the haversine formula?
A formula for the great-circle distance between two points on a sphere from their latitudes and longitudes. It is accurate for both short and long distances.
How do I convert degrees, minutes and seconds to decimal degrees?
Add degrees + minutes/60 + seconds/3600. For example 38° 53′ 51.36″ = 38.8976°. Use a negative value for south or west.
How do I calculate distance from speed and time?
Multiply speed by time, keeping the units consistent: distance = speed × time. A car averaging 60 mph for 2.5 hours covers 150 miles. Rearranged, time = distance ÷ speed and speed = distance ÷ time; the calculators on this page instead find the distance between two points from their coordinates.
Updated by Calculator.hair. How we build and check our calculators