Distance Calculator: Lat/Long, 2D and 3D

The distance between two points is the square root of the sum of the squared differences in each coordinate. For (1, 2) and (4, 6) that is √(3² + 4²) = 5. For two places on Earth, the calculator uses the haversine formula instead: New York City to Los Angeles is 2,445.56 miles in a straight line. Choose what you are measuring, then enter the two points.

Type a number and the answer appears straight away.

Your answer

Straight-line distance2,445.56 milesgreat-circle distance over the Earth's surface

Kilometers
3,935.75 km
Nautical miles
2,125.14 nmi
Initial compass bearing
273.7 degrees
Midpoint
39.5103, -97.1601
Central angle
35.395 degrees

Uses the haversine formula on a sphere with the mean Earth radius of 6,371.0088 km. The Earth is slightly flattened, so results can differ from survey-grade figures by up to about 0.5%. Road and flight distances are longer than this straight line.

The math behind it: Distance

2D: d = √((x2 − x1)² + (y2 − y1)²); 3D: d = √((x2 − x1)² + (y2 − y1)² + (z2 − z1)²); Earth: d = 2R × asin(√(sin²(Δφ/2) + cos φ1 × cos φ2 × sin²(Δλ/2)))

On a flat plane the distance formula is the Pythagorean theorem in disguise. The change in x and the change in y are the two legs of a right triangle, and the distance is its hypotenuse. From (1, 2) to (4, 6) the legs are 3 and 4, the distance squared is 25 and the distance is 5. The midpoint sits halfway along each axis, at (2.5, 4). The calculator also gives the Manhattan distance, 7 here, which is how far you would travel on a grid of streets moving only across and up.

In three dimensions, add the change in z. From (1, 2, 3) to (4, 6, 15) the changes are 3, 4 and 12, so the distance is √169 = 13, and the midpoint is (2.5, 4, 9). The same idea works for the diagonal of a box: a box 3 by 4 by 12 has a corner-to-corner diagonal of 13.

For places on Earth, enter each one's latitude and longitude in decimal degrees, with south and west as negative numbers. The haversine formula measures along the curve of a sphere using the mean Earth radius of 6,371.0088 km. New York City (40.7128, −74.006) to Los Angeles (34.0522, −118.2437) is 2,445.56 miles, 3,935.75 km or 2,125.14 nautical miles, with an initial compass bearing of 273.7 degrees. Chicago to Houston is 941.88 miles. One degree of longitude along the equator is 69.09 miles.

The Earth is slightly flattened at the poles, so a spherical answer can be off by up to about 0.5% compared with survey methods. Driving and flight routes are longer than the straight line. To estimate how long a trip takes, use the travel time calculator. The slope calculator finds the line through two points, the Pythagorean theorem calculator solves the triangle behind the formula, and the miles to km converter switches units.

Common questions

How do you find the distance between two points?

Subtract the x values and the y values, square both differences, add them and take the square root. For (1, 2) and (4, 6): √(3² + 4²) = √25 = 5.

How do you calculate distance using latitude and longitude?

Use the haversine formula, which measures along the surface of a sphere. With the mean Earth radius of 6,371.0088 km, New York City to Los Angeles comes to 3,935.75 km, or 2,445.56 miles.

How far is New York from Los Angeles in a straight line?

About 2,445.56 miles, or 3,935.75 km, measured as a great circle over the Earth's surface. The drive is much longer because roads do not follow the straight line.

What is the distance formula in 3D?

d = √((x2 − x1)² + (y2 − y1)² + (z2 − z1)²). From (1, 2, 3) to (4, 6, 15) the differences are 3, 4 and 12, so the distance is √169 = 13.

How many miles is one degree of longitude?

At the equator, one degree of longitude is 69.09 miles. It shrinks toward the poles because the lines of longitude meet there, while one degree of latitude stays close to the same everywhere.

You might also need

Checked and updated: