Skip to content
thecalculatorstudio

Distance Calculator: Between Two Points or Two Places

Choose what you are measuring between. For points on a plane or in space you get the Pythagorean distance. For two places on Earth you get the great-circle distance and the bearing.

Last reviewed

Distance

5

in the same units as the coordinates

Difference in x
3
Difference in y
4

The distance is the square root of the sum of the squared differences: the Pythagorean theorem in two or three dimensions.

Which distance do you mean?

“Distance between two points” can mean three different things, and the right formula depends on which:

  • Points on a flat plane, such as a graph, a floor plan or a map drawn to scale. Two coordinates each, x and y.
  • Points in space, such as a 3D model or a position in a room. Three coordinates each, x, y and z.
  • Two places on the Earth, given by latitude and longitude. The ground is curved, so the straight line on a flat map is not the shortest path.

Pick the one that matches your question. None of them gives a travel distance. A route by road, rail or air follows roads, tracks and corridors and is longer than the straight line, and needs a routing service to measure.

On a plane

The distance between (x₁, y₁) and (x₂, y₂) is the length of the hypotenuse of a right triangle whose sides are the differences in x and in y. This is the Pythagorean theorem:

distance = √((x₂ − x₁)² + (y₂ − y₁)²)

From (0, 0) to (3, 4): the differences are 3 and 4, and √(3² + 4²) = √25 = 5. Negative coordinates work the same way: from (−1, −1) to (2, 3) the differences are 3 and 4 again, so the distance is also 5.

In space

Add the difference in z:

distance = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²)

From (0, 0, 0) to (3, 4, 12): √(9 + 16 + 144) = √169 = 13. From (0, 0, 0) to (1, 1, 1) it is √3 = 1.7321, the length of the diagonal of a unit cube.

The units of the answer are the units of the coordinates. If they are in metres, the distance is in metres.

Between two places on Earth

For two latitude and longitude positions, the shortest path over the surface is an arc of a great circle, a circle that goes round the whole Earth, like the equator. The calculator finds its length with the haversine formula, which stays accurate for short distances too.

The Earth is not a perfect sphere. The World Geodetic System 1984 (WGS 84), the model that GPS uses, gives it a semi-major axis of 6,378,137 metres and a flattening of 1/298.257223563, which makes the semi-minor axis 6,356,752.3142 metres. The calculator uses a sphere with the same mean radius, (2a + b) ÷ 3 = 6,371.0087714 km. The result can differ from the distance on the true ellipsoid by a fraction of a percent, which is fine for planning and not for surveying.

Examples

These use city-centre coordinates, so they are approximate in themselves.

From To Distance Initial bearing
London (51.5074, −0.1278) Paris (48.8566, 2.3522) 343.56 km, 213.48 miles, 185.51 nautical miles 148.1°
New York (40.7128, −74.0060) Los Angeles (34.0522, −118.2437) 3,935.75 km, 2,445.56 miles 273.7°
Sydney (−33.8688, 151.2093) Melbourne (−37.8136, 144.9631) 713.43 km, 443.30 miles not shown

The bearing is the compass direction to set off in from the first place, in degrees clockwise from north. On a great circle it changes as you go, so the direction at the start is not the direction at the end. From Paris back to London the starting bearing is 330.0°, not 328.1°.

Checks you can do

The great circle lets you test the formula without a computer:

  • A quarter of the way round, from the equator to a pole or 90 degrees along the equator, is 10,007.56 km.
  • Half way round, to the opposite side of the Earth, is 20,015.11 km.
  • One degree of arc is 111.195 km, which is why a degree of latitude is about 111 km.
  • Over the pole. Two points at 60° north, 180° apart in longitude, are joined over the pole by an arc of 2 × (90 − 60) = 60°, which is 6,671.70 km.

Reading the units

Distances on Earth are shown in kilometres, miles and nautical miles. A mile is exactly 1.609344 km and a nautical mile exactly 1.852 km. A nautical mile is one minute of arc along a great circle, which is why it is used at sea and in the air.

Entering coordinates

  • Latitude is between −90 and 90, with north positive.
  • Longitude is between −180 and 180, with east positive.
  • Decimal degrees. If your coordinates are in degrees, minutes and seconds, convert them: degrees plus minutes ÷ 60 plus seconds ÷ 3,600.
  • Order. Latitude comes first, then longitude. Swapping them puts the place somewhere else.

Common mistakes

  • Using the plane formula for latitude and longitude. A degree of longitude gets shorter as you move away from the equator, so the flat-plane answer is wrong, and more so the further the points are.
  • Mixing up the sign of west and south. London is at −0.13 longitude, not +0.13.
  • Expecting the straight line to be the route. A great circle is the shortest path, not necessarily one you can travel.
  • Mixing units between the two points on a plane.

For the length of something, or for converting between miles, kilometres and other units, the length converter. For how quickly you cover a distance, the speed converter. For summarising a list of distances, the statistics calculator.

How it is calculated

On a plane or in space, the differences are squared and added and the square root is taken, in 40-digit decimal arithmetic. On the Earth, the latitudes and longitudes are turned into radians, the haversine of the central angle is worked out, and the angle is turned into a distance by multiplying by the radius. The initial bearing comes from the standard two-argument arctangent. Results are rounded for display only.

Frequently asked questions

What is the distance formula?

The square root of the sum of the squared differences in each coordinate. In two dimensions, √((x₂ − x₁)² + (y₂ − y₁)²). From (0, 0) to (3, 4) the distance is √(9 + 16) = 5.

How do I find the distance in three dimensions?

Add the squared difference in z. From (0, 0, 0) to (3, 4, 12) it is √(9 + 16 + 144) = √169 = 13.

How is the distance between two places on Earth worked out?

As a great-circle distance: the shortest path over the surface of a sphere, by the haversine formula. This calculator uses a sphere of radius 6,371.0087714 km, the mean radius of the WGS 84 ellipsoid. From London to Paris, using city-centre coordinates, it comes to about 343.6 km.

Is this the driving distance?

No. It is the straight-line distance, as the crow flies. A road, rail or flight route is longer, because it follows roads, tracks or air corridors. For a route distance you need a mapping or routing service.

How accurate is it?

Treating the Earth as a sphere is an approximation, and the result can differ from the distance on the true ellipsoid by a fraction of a percent. That is fine for most uses, but not for surveying.

Which way is latitude and longitude signed?

North latitudes and east longitudes are positive, south and west are negative. London is about 51.5 N and 0.13 W, so 51.5 and −0.13.

Related calculators

Sources