Distance Between Two Points Calculator

Find the distance between two points in 2D or 3D, or estimate the great-circle distance from two latitude and longitude coordinates.

Calculate

A
B

Distance between points

5

Worked example

From (1, 2) to (4, 6), the horizontal change is 3 and the vertical change is 4. The straight-line distance is 5 units.
From (1, 2) to (4, 6), the horizontal change is 3 and the vertical change is 4. The straight-line distance is 5 units.
Download GIFPlaying · repeats every 8 seconds

Formula and method

Use the same coordinate unit for both points on a plane or in space. The Earth mode takes decimal degrees and uses a spherical model for distance along the surface rather than a road route.

\[d=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2}\]
\[d((1,2),(4,6))=\sqrt{3^2+4^2}=5\]
\[d((1,2,3),(4,6,15))=\sqrt{3^2+4^2+12^2}=13\]

How to use the calculator

Choose a mode based on the coordinates you have. Use 2D for points on a flat grid, 3D when height or depth is part of the same coordinate system, and geographic mode for latitude and longitude. Each mode measures the shortest distance in its own model.

  1. For 2D or 3D, enter the coordinates for each point with the same unit on all axes. If x is in meters and z is in centimeters, convert them to a common unit first.
  2. For a geographic calculation, enter latitude first and longitude second for each point. Use decimal degrees, with negative latitude for the south and negative longitude for the west.
  3. Read the distance and the working below it. Use the coordinate differences to check your input in 2D or 3D. The geographic result gives kilometers and miles.

Worked examples

Find the distance between (−2, 1) and (4, 9)

Moving between the points changes x by 6 and y by 8. They form the two legs of a right triangle. The diagonal is 10 units long. If the original coordinates are in meters, the answer is 10 meters.

\[\sqrt{(4-(-2))^2+(9-1)^2}=\sqrt{6^2+8^2}=10\]

One degree of longitude at the equator

Enter latitude 0 and longitude 0 for the first point, then latitude 0 and longitude 1 for the second. The short arc covers one degree of the Earth’s circumference at the equator. Using a mean Earth radius of about 6,371 km gives about 111.2 km.

\[6371.0088\times\frac{\pi}{180}\approx111.2\,\mathrm{km}\]

How to read the result

Cartesian distance comes from squaring the changes along the axes, adding them and taking the square root. For 3D, add the squared change in z. Geographic mode uses the haversine formula on a spherical Earth. It estimates the surface arc and ignores changes in elevation.

Frequently asked questions

What happens if I swap the two points?

The signed coordinate differences reverse. The squared differences and the distance remain the same. Two identical points have distance zero.

What latitude and longitude ranges are accepted?

Latitude runs from −90° to 90° and longitude from −180° to 180°. Convert degrees, minutes and seconds to decimal degrees before entering them.

Can I use this for driving distance?

For a route, use road or trail directions and add the route segments. The geographic result measures the shortest surface arc between the two coordinates.