# Geographical distance

Geodesy :
Fundamentals
Geodesy
Geodynamics
Geomatics
History :
Concepts
Geographical distance
Geoid
Figure of the Earth (radius and circumference)
Geodetic coordinates
Geodetic datum
Geodesic
Horizontal position representation
Latitude / Longitude
Map projection
Reference ellipsoid
Satellite geodesy
Spatial reference system
Spatial relations
Vertical positions :
Technologies
Global Nav. Sat. Systems (GNSSs)
Global Pos. System (GPS)
GLONASS (Russia)
BeiDou (BDS) (China)
Galileo (Europe)
NAVIC (India)
Quasi-Zenith Sat. Sys. (QZSS) (Japan)
Discrete Global Grid and Geocoding :
Standards (history) NGVD 29 Sea Level Datum 1929 OSGB36 Ordnance Survey Great Britain 1936 SK-42 Systema Koordinat 1942 goda ED50 European Datum 1950 SAD69 South American Datum 1969 GRS 80 Geodetic Reference System 1980 ISO 6709 Geographic point coord. 1983 NAD 83 North American Datum 1983 WGS 84 World Geodetic System 1984 NAVD 88 N. American Vertical Datum 1988 ETRS89 European Terrestrial Ref. Sys. 1989 GCJ-02 Chinese obfuscated datum 2002 Geo URI Internet link to a point 2010
International Terrestrial Reference System
Spatial Reference System Identifier (SRID)
Universal Transverse Mercator (UTM) :
vte :
Geographical distance or geodetic distance is the distance measured along the surface of the Earth, or the shortest arch length.
The formulae in this article calculate distances between points which are defined by geographical coordinates in terms of latitude and longitude. This distance is an element in solving the second (inverse) geodetic problem.

## Introduction

Calculating the distance between geographical coordinates is based on some level of abstraction; it does not provide an exact distance, which is unattainable if one attempted to account for every irregularity in the surface of the Earth. Common abstractions for the surface between two geographic points are:
* Flat surface;
* Spherical surface;
* Ellipsoidal surface.
All abstractions above ignore changes in elevation. Calculation of distances which account for changes in elevation relative to the idealized surface are not discussed in this article.

### Classification of Formulae based on Approximation

* Tunnel-distance based approximations: Flat surface, Gauss-mid-latitude; $\max |\Delta D_{\text{error}}|\propto D^{3}$
* 0-th-order approximation: Spherical surface; $\max |\Delta D_{\text{error}}|\propto D$
* higher-order approximations based on Ellipsoid: $f^{1}$: Andoyer(1932); Andoyer-Lambert(1942), $f^{2}$: Andoyer-Lambert-Thomas(1970), $f^{3}$: Vincenty(1975), $f^{6}$: Kaney(2011); $\max |\Delta D_{\text{error}}|\propto D$ on the hemisphere
The theoretical estimations of error are added in above and $f$ is the flattening of the Earth.

### Nomenclature

Arc distance, $D,\,\!$ is the minimum distance along the surface of sphere/ellipsoid calculated between two points, $P_{1}\,\!$ and $P_{2}\,\!$. Whereas, the tunnel distance, or chord length, $D_{\textrm {t}}$, is measured along Cartesian straight line. The geographical coordinates of the two points, as (latitude, longitude) pairs, are $(\phi _{1},\lambda _{1})\,\!$ and $(\phi _{2},\lambda _{2}),\,\!$ respectively. Which of the two points is designated as $P_{1}\,\!$ is not important for the calculation of distance.
Latitude $\phi \,\!$ and longitude $\lambda \,\!$ coordinates on maps are usually expressed in degrees. In the given forms of the formulae below, one or more values must be expressed in the specified units to obtain the correct result. Where geographic coordinates are used as the argument of a trigonometric function, the values may be expressed in any angular units compatible with the method used to determine the value of the trigonometric function. Many electronic calculators allow calculations of trigonometric functions in either degrees or radians. The calculator mode must be compatible with the units used for geometric coordinates.
Differences in latitude and longitude are labeled and calculated as follows:
    ${\begin{aligned}\Delta \phi &=\phi _{2}-\phi _{1};\\\Delta \lambda &=\lambda _{2}-\lambda _{1}.\end{aligned}}\,\!$
It is not important whether the result is positive or negative when used in the formulae below.
"Mean latitude" is labeled and calculated as follows:
    $\phi _{\mathrm {m} }={\frac {\phi _{1}+\phi _{2}}{2}}.\,\!$
Unless specified otherwise, the radius of the Earth for the calculations below is:
    $R\,\!$ = 6,371.009 kilometers = 3,958.761 statute miles = 3,440.069 nautical miles.
$D_{\,}\!$ = Distance between the two points, as measured along the surface of the Earth and in the same units as the value used for radius unless specified otherwise.

### Singularities and discontinuity of latitude/longitude

The approximation of sinusoidal functions of $\Delta \lambda$, appearing in some flat-surface formulae below, may induce singularity and discontinuity. It may also degrade the accuracy in the case of higher latitude.
Longitude has singularities at the Poles (longitude is undefined) and a discontinuity at the ±180° meridian. Also, planar projections of the circles of constant latitude are highly curved near the Poles. Hence, the above equations for delta latitude/longitude ($\Delta \phi \!$, $\Delta \lambda \!$) and mean latitude ($\phi _{\mathrm {m} }\!$) may not give the expected answer for positions near the Poles or the ±180° meridian. Consider e.g. the value of $\Delta \lambda \!$ ("east displacement") when $\lambda _{1}\!$ and $\lambda _{2}\!$ are on either side of the ±180° meridian, or the value of $\phi _{\mathrm {m} }\!$ ("mean latitude") for the two positions ($\phi _{1}\!$=89°, $\lambda _{1}\!$=45°) and ($\phi _{2}\!$=89°, $\lambda _{2}\!$=−135°).
If a calculation based on latitude/longitude should be valid for all Earth positions, it should be verified that the discontinuity and the Poles are handled correctly. Another solution is to use n-vector instead of latitude/longitude, since this representation does not have discontinuities or singularities.

## Flat-surface approximation formulae for very short distance

A planar approximation for the surface of the Earth may be useful over very small distances. It approximates the arc length, $D$, to the tunnel distance, $D_{\textrm {t}}$, or omits the conversion between arc and chord lengths shown below.
The shortest distance between two points in plane is a Cartesian straight line. The Pythagorean theorem is used to calculate the distance between points in a plane.
Even over short distances, the accuracy of geographic distance calculations which assume a flat Earth depend on the method by which the latitude and longitude coordinates have been projected onto the plane. The projection of latitude and longitude coordinates onto a plane is the realm of cartography.
The formulae presented in this section provide varying degrees of accuracy.

### Spherical Earth approximation formulae

The tunnel distance is calculated on Spherical Earth. This formula takes into account the variation in distance between meridians with latitude:
    ${\begin{aligned}D&=R{\sqrt {\left(2\sin {\frac {\Delta \phi }{2}}\,\cos {\frac {\Delta \lambda }{2}}\right)^{2}+\left(2\cos \phi _{\textrm {m}}\sin {\frac {\Delta \lambda }{2}}\right)^{2}}}\\&\approx R{\sqrt {\left(\Delta \phi \,\cos {\frac {\Delta \lambda }{2}}\right)^{2}+\left(2\cos \phi _{\textrm {m}}\sin {\frac {\Delta \lambda }{2}}\right)^{2}}}\ .\end{aligned}}$
The square root appearing above can be eliminated for such applications as ordering locations by distance in a database query. On the other hand, some methods for computing nearest neighbors, such as the vantage-point tree, require that the distance metric obey the triangle inequality, in which case the square root must be retained.

#### In the case of medium or low latitude

The above is furthermore simplified by approximating sinusoidal functions of ${\frac {\Delta \lambda }{2}}$, justified except for high latitude:
    $D\approx R{\sqrt {(\Delta \phi )^{2}+(\cos(\phi _{\mathrm {m} })\Delta \lambda )^{2}}}$.

### Ellipsoidal Earth approximation formulae

The above formula is extended for ellipsoidal Earth:
    $D\approx {\sqrt {\left(M\left(\phi _{\textrm {m}}\right)\Delta \phi \,\cos {\frac {\Delta \lambda }{2}}\right)^{2}+\left(2N\left(\phi _{\textrm {m}}\right)\cos \phi _{\textrm {m}}\sin {\frac {\Delta \lambda }{2}}\right)^{2}}}$,
where $M\,\!$ and $N\,\!$ are the meridional and its perpendicular, or "normal", radii of curvature of Earth (See also "Geographic coordinate conversion" for their formulas).
It is derived by the approximation of $\left(\cos \phi _{\textrm {m}}\sin {\frac {\Delta \lambda }{2}}\Delta \phi \right)^{2}\approx 0$ in the square root.

#### In the case of medium or low latitude

The above is furthermore simplified by approximating sinusoidal functions of ${\frac {\Delta \lambda }{2}}$, justified except for high latitude as above:
    $D\approx {\sqrt {(M(\phi _{\mathrm {m} })\Delta \phi )^{2}+(N(\phi _{\mathrm {m} })\cos \phi _{\mathrm {m} }\Delta \lambda )^{2}}}.$

#### FCC's formula

The Federal Communications Commission (FCC) prescribes the following formulae for distances not exceeding 475 kilometres (295 mi):
    $D\approx {\sqrt {(K_{1}\Delta \phi )^{2}+(K_{2}\Delta \lambda )^{2}}},$
    where
       $D\,\!$ = Distance in kilometers;
       $\Delta \phi \,\!$ and $\Delta \lambda \,\!$ are in degrees;
       $\phi _{\mathrm {m} }\,\!$ must be in units compatible with the method used for determining $\cos \phi _{\mathrm {m} };\,\!$
       ${\begin{aligned}K_{1}&=111.13209-0.56605\cos(2\phi _{\mathrm {m} })+0.00120\cos(4\phi _{\mathrm {m} });\\K_{2}&=111.41513\cos(\phi _{\mathrm {m} })-0.09455\cos(3\phi _{\mathrm {m} })+0.00012\cos(5\phi _{\mathrm {m} }).\end{aligned}}\,\!$
    Where $K_{1}$ and $K_{2}$ are in units of kilometers per arc degree. They are derived from radii of curvature of Earth as follows:
       $K_{1}=M(\phi _{\mathrm {m} }){\frac {\pi }{180}}\,\!$ = kilometers per arc degree of latitude difference;
       $K_{2}=\cos(\phi _{\mathrm {m} })N(\phi _{\mathrm {m} }){\frac {\pi }{180}}\,\!$ = kilometers per arc degree of longitude difference;
    Note that the expressions in the FCC formula are derived from the truncation of the binomial series expansion form of $M\,\!$ and $N\,\!$, set to the Clarke 1866 reference ellipsoid. For a more computationally efficient implementation of the formula above, multiple applications of cosine can be replaced with a single application and use of recurrence relation for Chebyshev polynomials.

### Polar coordinate flat-Earth formula

$D=R{\sqrt {\theta _{1}^{2}\;{\boldsymbol {+}}\;\theta _{2}^{2}\;\mathbf {-} \;2\theta _{1}\theta _{2}\cos(\Delta \lambda )}},$
    where the colatitude values are in radians: $\theta ={\frac {\pi }{2}}-\phi .$
    For a latitude measured in degrees, the colatitude in radians may be calculated as follows: $\theta ={\frac {\pi }{180}}(90^{\circ }-\phi ).\,\!$

## Spherical-surface formulae

If one is willing to accept a possible error of 0.5%, one can use formulas of spherical trigonometry on the sphere that best approximates the surface of the Earth.
The shortest distance along the surface of a sphere between two points on the surface is along the great-circle which contains the two points.
The great-circle distance article gives the formula for calculating the shortest arch length $D$ on a sphere about the size of the Earth. That article includes an example of the calculation. For example, from tunnel distance $D_{\textrm {t}}$,
    $D=2R\arcsin {\frac {D_{\textrm {t}}}{2R}}.$
For short distances ($D\ll R$),
    $D=D_{\textrm {t}}\left(1+{\frac {1}{24}}\left({\frac {D_{\textrm {t}}}{R}}\right)^{2}+\cdots \right).$

### Tunnel distance

A tunnel between points on Earth is defined by a Cartesian line through three-dimensional space between the points of interest. The tunnel distance $D_{\textrm {t}}=2R\sin {\frac {D}{2R}}$ is the great-circle chord length and may be calculated as follows for the corresponding unit sphere:
    ${\begin{aligned}\Delta {X}&=\cos(\phi _{2})\cos(\lambda _{2})-\cos(\phi _{1})\cos(\lambda _{1});\\\Delta {Y}&=\cos(\phi _{2})\sin(\lambda _{2})-\cos(\phi _{1})\sin(\lambda _{1});\\\Delta {Z}&=\sin(\phi _{2})-\sin(\phi _{1});\\D_{\textrm {t}}&=R{\sqrt {(\Delta {X})^{2}+(\Delta {Y})^{2}+(\Delta {Z})^{2}}}\\&=2R{\sqrt {\sin ^{2}{\frac {\Delta \phi }{2}}+\left(\cos ^{2}{\frac {\Delta \phi }{2}}-\sin ^{2}\phi _{\textrm {m}}\right)\sin ^{2}{\frac {\Delta \lambda }{2}}}}\\&=2R{\sqrt {\left(\sin {\frac {\Delta \lambda }{2}}\cos \phi _{\textrm {m}}\right)^{2}+\left(\cos {\frac {\Delta \lambda }{2}}\sin {\frac {\Delta \phi }{2}}\right)^{2}}}.\end{aligned}}$

## Ellipsoidal-surface formulae

An ellipsoid approximates the surface of the Earth much better than a sphere or a flat surface does. The shortest distance along the surface of an ellipsoid between two points on the surface is along the geodesic. Geodesics follow more complicated paths than great circles and in particular, they usually don't return to their starting positions after one circuit of the Earth. This is illustrated in the figure on the right where f is taken to be 1/50 to accentuate the effect. Finding the geodesic between two points on the Earth, the so-called inverse geodetic problem, was the focus of many mathematicians and geodesists over the course of the 18th and 19th centuries with major contributions by Clairaut, Legendre, Bessel, and Helmert English translation of Astron. Nachr. 4, 241–254 (1825). Errata. Rapp provides a good summary of this work.
Methods for computing the geodesic distance are widely available in geographical information systems, software libraries, standalone utilities, and online tools. The most widely used algorithm is by Vincenty, who uses a series which is accurate to third order in the flattening of the ellipsoid, i.e., about 0.5 mm; however, the algorithm fails to converge for points that are nearly antipodal. (For details, see Vincenty's formulae.) This defect is cured in the algorithm given by Karney, who employs series which are accurate to sixth order in the flattening. This results in an algorithm which is accurate to full double precision and which converges for arbitrary pairs of points on the Earth. This algorithm is implemented in GeographicLib.
The exact methods above are feasible when carrying out calculations on a computer. They are intended to give millimeter accuracy on lines of any length; one can use simpler formulas if one doesn't need millimeter accuracy, or if one does need millimeter accuracy but the line is short.
The short-line methods have been studied by several researchers. Rapp, Chap. 6, describes the Puissant method, the Gauss mid-latitude method, and the Bowring method. Karl Hubeny got the expanded series of Gauss mid-latitude one represented as the correction to flat-surface one.

### Lambert's formula for long lines

Historically, the long-line formulae were derived in the form of expansion series with regard to flattening $f$.
Lambert's formulae use the first-order correction and reduced latitude, $\beta =\arctan \left((1-f)\tan \phi \right)$, for better accuracy. They give accuracy on the order of 10 meters over thousands of kilometers.
First convert the latitudes $\scriptstyle \phi _{1}$, $\scriptstyle \phi _{2}$ of the two points to reduced latitudes $\scriptstyle \beta _{1}$, $\scriptstyle \beta _{2}$. Then calculate the central angle $\sigma$ in radians between two points $(\beta _{1},\;\lambda _{1})$ and $(\beta _{2},\;\lambda _{2})$ on a sphere using the Great-circle distance method (haversine formula), with longitudes $\lambda _{1}\;$ and $\lambda _{2}\;$ being the same on the sphere as on the spheroid.
    $P={\frac {\beta _{1}+\beta _{2}}{2}}\qquad Q={\frac {\beta _{2}-\beta _{1}}{2}}$
    $X=(\sigma -\sin \sigma ){\frac {\sin ^{2}P\cos ^{2}Q}{\cos ^{2}{\frac {\sigma }{2}}}}\qquad \qquad Y=(\sigma +\sin \sigma ){\frac {\cos ^{2}P\sin ^{2}Q}{\sin ^{2}{\frac {\sigma }{2}}}}$
    D=a(σ−f/2 (X+Y)){\textstyle D=a{\bigl\sigma -{\tfrac {f}{2}}(X+Y){\bigr )}},
where $a$ is the equatorial radius of the chosen spheroid.
On the GRS 80 spheroid Lambert's formula is off by
    0 North 0 West to 40 North 120 West, 12.6 meters
    0N 0W to 40N 60W, 6.6 meters
    40N 0W to 40N 60W, 0.85 meter

### Gauss mid-latitude method for short lines

It has the similar form of the arc length converted from tunnel distance. Detailed formulas are given by Rapp, §6.4. It is consistent with the above-mentioned flat-surface formulae apparently.
    $D=2N\left(\phi _{\textrm {m}}\right)\arcsin {\sqrt {\left(\sin {\frac {\Delta \lambda }{2}}\cos \phi _{\textrm {m}}\right)^{2}+\left(\cos {\frac {\Delta \lambda }{2}}\sin \left({\frac {\Delta \phi }{2}}{\frac {M\left(\phi _{\textrm {m}}\right)}{N\left(\phi _{\textrm {m}}\right)}}\right)\right)^{2}}}.$

### Bowring's method for short lines

Bowring maps the points to a sphere of radius R′, with latitude and longitude represented as φ′ and λ′. Define
    $A={\sqrt {1+e'^{2}\cos ^{4}\phi _{1}}},\quad B={\sqrt {1+e'^{2}\cos ^{2}\phi _{1}}},$
where the second eccentricity squared is
    $e'^{2}={\frac {a^{2}-b^{2}}{b^{2}}}={\frac {f(2-f)}{(1-f)^{2}}}.$
The spherical radius is
    $R'={\frac {\sqrt {1+e'^{2}}}{B^{2}}}a.$
(The Gaussian curvature of the ellipsoid at φ$_1$ is 1/R′$^2$.) The spherical coordinates are given by
    ${\begin{aligned}\tan \phi _{1}'&={\frac {\tan \phi _{1}}{B}},\\\Delta \phi '&={\frac {\Delta \phi }{B}}{\biggl1+{\frac {3e'^{2}}{4B^{2}}}(\Delta \phi )\sin(2\phi _{1}+{\tfrac {2}{3}}\Delta \phi ){\biggr ]},\\\Delta \lambda '&=A\Delta \lambda ,\end{aligned}}$
where $\Delta \phi =\phi _{2}-\phi _{1}$, $\Delta \phi '=\phi _{2}'-\phi _{1}'$, $\Delta \lambda =\lambda _{2}-\lambda _{1}$, $\Delta \lambda '=\lambda _{2}'-\lambda _{1}'$. The resulting problem on the sphere may be solved using the techniques for great-circle navigation to give approximations for the spheroidal distance and bearing. Detailed formulas are given by Rapp §6.5, Bowring, and Karney.

## Altitude correction

The variation in altitude from the topographical or ground level down to the sphere's or ellipsoid's surface, also changes the scale of distance measurements. The slant distance s (chord length) between two points can be reduced to the arc length on the ellipsoid surface S as:
    $S-s=-0.5(h_{1}+h_{2})s/R-0.5(h_{1}-h_{2})^{2}/s$
where R is evaluated from Earth's azimuthal radius of curvature and h are ellipsoidal heights are each point. The first term on the right-hand side of the equation accounts for the mean elevation and the second term for the inclination. A further reduction of the above Earth normal section length to the ellipsoidal geodesic length is often negligible.