# Geographic coordinate conversion

In geodesy, conversion among different geographic coordinate systems is made necessary by the different geographic coordinate systems in use across the world and over time. Coordinate conversion is composed of a number of different types of conversion: format change of geographic coordinates, conversion of coordinate systems, or transformation to different geodetic datums. Geographic coordinate conversion has applications in cartography, surveying, navigation and geographic information systems.
In geodesy, geographic coordinate conversion is defined as translation among different coordinate formats or map projections all referenced to the same geodetic datum. A geographic coordinate transformation is a translation among different geodetic datums. Both geographic coordinate conversion and transformation will be considered in this article.
This article assumes readers are already familiar with the content in the articles geographic coordinate system and geodetic datum.

## Change of units and format

Informally, specifying a geographic location usually means giving the location's latitude and longitude. The numerical values for latitude and longitude can occur in a number of different units or formats:
* sexagesimal degree: degrees, minutes, and seconds : 40° 26′ 46″ N 79° 58′ 56″ W
* degrees and decimal minutes: 40° 26.767′ N 79° 58.933′ W
* decimal degrees: +40.446 -79.982
There are 60 minutes in a degree and 60 seconds in a minute. Therefore, to convert from a degrees minutes seconds format to a decimal degrees format, one may use the formula
    ${\rm {{decimal\ degrees}={\rm {{degrees}+{\frac {\rm {minutes}}{60}}+{\frac {\rm {seconds}}{3600}}}}}}$.
To convert back from decimal degree format to degrees minutes seconds format,
    ${\begin{aligned}{\rm {absDegrees}}&=|{\rm {{decimal\ degrees}|}}\\{\rm {floorAbsDegrees}}&=\lfloor {\rm {{absDegrees}\rfloor }}\\{\rm {degrees}}&=\operatorname {sgn}({\rm {{decimal\ degrees})\times {\rm {floorAbsDegrees}}}}\\{\rm {minutes}}&=\lfloor 60\times ({\rm {{absDegrees}-{\rm {{floorAbsDegrees})\rfloor }}}}\\{\rm {seconds}}&=3600\times ({\rm {{absDegrees}-{\rm {{floorAbsDegrees})-60\times {\rm {minutes}}}}}}\\\end{aligned}}$
where ${\rm {absDegrees}}$ and ${\rm {floorAbsDegrees}}$ are just temporary variables to handle both positive and negative values properly.

## Coordinate system conversion

A coordinate system conversion is a conversion from one coordinate system to another, with both coordinate systems based on the same geodetic datum. Common conversion tasks include conversion between geodetic and earth-centered, earth-fixed (ECEF) coordinates and conversion from one type of map projection to another.

### From geodetic to ECEF coordinates

Geodetic coordinates (latitude $\ \phi$, longitude $\ \lambda$, height $h$) can be converted into ECEF coordinates using the following equation:
    ${\begin{aligned}X&=\left(N(\phi )+h\right)\cos {\phi }\cos {\lambda }\\Y&=\left(N(\phi )+h\right)\cos {\phi }\sin {\lambda }\\Z&=\left({\frac {b^{2}}{a^{2}}}N(\phi )+h\right)\sin {\phi }\\&=\left((1-e^{2})N(\phi )+h\right)\sin {\phi }\\&=\left((1-f)^{2}N(\phi )+h\right)\sin {\phi }\end{aligned}}$
where
    $N(\phi )={\frac {a^{2}}{\sqrt {a^{2}\cos ^{2}\phi +b^{2}\sin ^{2}\phi }}}={\frac {a}{\sqrt {1-e^{2}\sin ^{2}\phi }}}={\frac {a}{\sqrt {1-{\frac {e^{2}}{1+\cot ^{2}\phi }}}}},$
and $a$ and $b$ are the equatorial radius (semi-major axis) and the polar radius (semi-minor axis), respectively. $e^{2}=1-{\frac {b^{2}}{a^{2}}}$ is the square of the first numerical eccentricity of the ellipsoid. $f=1-{\frac {b}{a}}$ is the flattening of the ellipsoid. The prime vertical radius of curvature $\,N(\phi )$ is the distance from the surface to the Z-axis along the ellipsoid normal.

#### Properties

The following condition holds for the longitude in the same way as in the geocentric coordinates system:
    ${\frac {X}{\cos \lambda }}-{\frac {Y}{\sin \lambda }}=0.$
And the following holds for the latitude:
    ${\frac {p}{\cos \phi }}-{\frac {Z}{\sin \phi }}-e^{2}N(\phi )=0,$
where $p={\sqrt {X^{2}+Y^{2}}}$, as the parameter $h$ is eliminated by subtracting
    ${\frac {p}{\cos \phi }}=N+h$
and
    ${\frac {Z}{\sin \phi }}={\frac {b^{2}}{a^{2}}}N+h.$
The following holds furthermore, derived from dividing above equations:
    ${\frac {Z}{p}}\cot \phi =1-{\frac {e^{2}N}{N+h}}.$

#### Orthogonality

The orthogonality of the coordinates is confirmed via differentiation:
    ${\begin{aligned}{\begin{pmatrix}dX\\dY\\dZ\end{pmatrix}}&={\begin{pmatrix}-\sin \lambda &-\sin \phi \cos \lambda &\cos \phi \cos \lambda \\\cos \lambda &-\sin \phi \sin \lambda &\cos \phi \sin \lambda \\0&\cos \phi &\sin \phi \\\end{pmatrix}}{\begin{pmatrix}dE\\dN\\dU\end{pmatrix}},\\[3pt]{\begin{pmatrix}dE\\dN\\dU\end{pmatrix}}&={\begin{pmatrix}\left(N(\phi )+h\right)\cos \phi &0&0\\0&M(\phi )+h&0\\0&0&1\\\end{pmatrix}}{\begin{pmatrix}d\lambda \\d\phi \\dh\end{pmatrix}},\end{aligned}}$
where
    $M(\phi )={\frac {a\left(1-e^{2}\right)}{\left(1-e^{2}\sin ^{2}\phi \right)^{\frac {3}{2}}}}=N(\phi ){\frac {1-e^{2}}{1-e^{2}\sin ^{2}\phi }}$
(see also "Meridian arc on the ellipsoid").

### From ECEF to geodetic coordinates
#### Conversion for the longitude

The conversion of ECEF coordinates to longitude is:
    $\lambda =\operatorname {atan2} (Y,X)$.
where atan2 is the quadrant-resolving arc-tangent function. The geocentric longitude and geodetic longitude have the same value; this is true for Earth and other similar shaped planets because they have a large amount of rotational symmetry around their spin axis (see triaxial ellipsoidal longitude for a generalization).

#### Simple iterative conversion for latitude and height

The conversion for the latitude and height involves a circular relationship involving N, which is a function of latitude:
    ${\frac {Z}{p}}\cot \phi =1-{\frac {e^{2}N}{N+h}}$,
    $h={\frac {p}{\cos \phi }}-N$.
It can be solved iteratively, for example, starting with a first guess h≈0 then updating N. More elaborate methods are shown below. The procedure is, however, sensitive to small accuracy due to $N$ and $h$ being maybe 10$^6$ apart.

#### Newton–Raphson method

The following Bowring's irrational geodetic-latitude equation, derived simply from the above properties, is efficient to be solved by Newton–Raphson iteration method:
    $\kappa -1-{\frac {e^{2}a\kappa }{\sqrt {p^{2}+\left(1-e^{2}\right)Z^{2}\kappa ^{2}}}}=0,$
where $\kappa ={\frac {p}{Z}}\tan \phi$ and $p={\sqrt {X^{2}+Y^{2}}}$ as before. The height is calculated as:
    ${\begin{aligned}h&=e^{-2}\left(\kappa ^{-1}-{\kappa _{0}}^{-1}\right){\sqrt {p^{2}+Z^{2}\kappa ^{2}}},\\\kappa _{0}&\triangleq \left(1-e^{2}\right)^{-1}.\end{aligned}}$
The iteration can be transformed into the following calculation:
    $\kappa _{i+1}={\frac {c_{i}+\left(1-e^{2}\right)Z^{2}\kappa _{i}^{3}}{c_{i}-p^{2}}}=1+{\frac {p^{2}+\left(1-e^{2}\right)Z^{2}\kappa _{i}^{3}}{c_{i}-p^{2}}},$
where $c_{i}={\frac {\left(p^{2}+\left(1-e^{2}\right)Z^{2}\kappa _{i}^{2}\right)^{\frac {3}{2}}}{ae^{2}}}.$
The constant $\,\kappa _{0}$ is a good starter value for the iteration when $h\approx 0$. Bowring showed that the single iteration produces a sufficiently accurate solution. He used extra trigonometric functions in his original formulation.

#### Ferrari's solution

The quartic equation of $\kappa$, derived from the above, can be solved by Ferrari's solution to yield:
    ${\begin{aligned}\zeta &=\left(1-e^{2}\right){\frac {z^{2}}{a^{2}}},\\[4pt]\rho &={\frac {1}{6}}\left({\frac {p^{2}}{a^{2}}}+\zeta -e^{4}\right),\\[4pt]s&={\frac {e^{4}\zeta p^{2}}{4\rho ^{3}a^{2}}},\\[4pt]t&={\sqrt[{3}]{1+s+{\sqrt {s(s+2)}}}},\\[4pt]u&=\rho \left(t+1+{\frac {1}{t}}\right),\\[4pt]v&={\sqrt {u^{2}+e^{4}\zeta }},\\[4pt]w&=e^{2}{\frac {u+v-\zeta }{2v}},\\[4pt]\kappa &=1+e^{2}{\frac {{\sqrt {u+v+w^{2}}}+w}{u+v}}.\end{aligned}}$

##### The application of Ferrari's solution

A number of techniques and algorithms are available but the most accurate, according to Zhu, is the following procedure established by Heikkinen, as cited by Zhu. This overlaps with above. It is assumed that geodetic parameters $\{a,\,b,\,e\}$ are known
    ${\begin{aligned}a&=6378137.0{\text{ m. Earth Equatorial Radius}}\\[3pt]b&=6356752.3142{\text{ m. Earth Polar Radius}}\\[3pt]e^{2}&={\frac {a^{2}-b^{2}}{a^{2}}}\\[3pt]e'^{2}&={\frac {a^{2}-b^{2}}{b^{2}}}\\[3pt]p&={\sqrt {X^{2}+Y^{2}}}\\[3pt]F&=54b^{2}Z^{2}\\[3pt]G&=p^{2}+\left(1-e^{2}\right)Z^{2}-e^{2}\left(a^{2}-b^{2}\right)\\[3pt]c&={\frac {e^{4}Fp^{2}}{G^{3}}}\\[3pt]s&={\sqrt[{3}]{1+c+{\sqrt {c^{2}+2c}}}}\\[3pt]k&=s+1+{\frac {1}{s}}\\[3pt]P&={\frac {F}{3k^{2}G^{2}}}\\[3pt]Q&={\sqrt {1+2e^{4}P}}\\[3pt]r_{0}&={\frac {-Pe^{2}p}{1+Q}}+{\sqrt {{\frac {1}{2}}a^{2}\left(1+{\frac {1}{Q}}\right)-{\frac {P\left(1-e^{2}\right)Z^{2}}{Q(1+Q)}}-{\frac {1}{2}}Pp^{2}}}\\[3pt]U&={\sqrt {\left(p-e^{2}r_{0}\right)^{2}+Z^{2}}}\\[3pt]V&={\sqrt {\left(p-e^{2}r_{0}\right)^{2}+\left(1-e^{2}\right)Z^{2}}}\\[3pt]z_{0}&={\frac {b^{2}Z}{aV}}\\[3pt]h&=U\left(1-{\frac {b^{2}}{aV}}\right)\\[3pt]\phi &=\arctan \left[{\frac {Z+e'^{2}z_{0}}{p}}\right]\\[3pt]\lambda &=\operatorname {arctan2} [Y,\,X]\end{aligned}}$
Note: arctan2[Y, X] is the four-quadrant inverse tangent function.

#### Power series

For small e$^2$ the power series
    $\kappa =\sum _{i\geq 0}\alpha _{i}e^{2i}$
starts with
    ${\begin{aligned}\alpha _{0}&=1;\\\alpha _{1}&={\frac {a}{\sqrt {Z^{2}+p^{2}}}};\\\alpha _{2}&={\frac {aZ^{2}{\sqrt {Z^{2}+p^{2}}}+2a^{2}p^{2}}{2\left(Z^{2}+p^{2}\right)^{2}}}.\end{aligned}}$

### Geodetic to/from ENU coordinates

To convert from geodetic coordinates to local tangent plane (ENU) coordinates is a two-stage process:
* Convert geodetic coordinates to ECEF coordinates
* Convert ECEF coordinates to local ENU coordinates

#### From ECEF to ENU

To transform from ECEF coordinates to the local coordinates we need a local reference point. Typically, this might be the location of a radar. If a radar is located at $\left\{X_{r},\,Y_{r},\,Z_{r}\right\}$ and an aircraft at $\left\{X_{p},\,Y_{p},\,Z_{p}\right\}$, then the vector pointing from the radar to the aircraft in the ENU frame is
    ${\begin{bmatrix}x\\y\\z\end{bmatrix}}={\begin{bmatrix}-\sin \lambda _{r}&\cos \lambda _{r}&0\\-\sin \phi _{r}\cos \lambda _{r}&-\sin \phi _{r}\sin \lambda _{r}&\cos \phi _{r}\\\cos \phi _{r}\cos \lambda _{r}&\cos \phi _{r}\sin \lambda _{r}&\sin \phi _{r}\end{bmatrix}}{\begin{bmatrix}X_{p}-X_{r}\\Y_{p}-Y_{r}\\Z_{p}-Z_{r}\end{bmatrix}}$
Note: $\ \phi$ is the geodetic latitude; the geocentric latitude is inappropriate for representing vertical direction for the local tangent plane and must be converted if necessary.

#### From ENU to ECEF

This is just the inversion of the ECEF to ENU transformation so
    ${\begin{bmatrix}X_{p}\\Y_{p}\\Z_{p}\end{bmatrix}}={\begin{bmatrix}-\sin \lambda _{r}&-\sin \phi _{r}\cos \lambda _{r}&\cos \phi _{r}\cos \lambda _{r}\\\cos \lambda _{r}&-\sin \phi _{r}\sin \lambda _{r}&\cos \phi _{r}\sin \lambda _{r}\\0&\cos \phi _{r}&\sin \phi _{r}\end{bmatrix}}{\begin{bmatrix}x\\y\\z\end{bmatrix}}+{\begin{bmatrix}X_{r}\\Y_{r}\\Z_{r}\end{bmatrix}}$

### Conversion across map projections

Conversion of coordinates and map positions among different map projections reference to the same datum may be accomplished either through direct translation formulas from one projection to another, or by first converting from a projection $A$ to an intermediate coordinate system, such as ECEF, then converting from ECEF to projection $B$. The formulas involved can be complex and in some cases, such as in the ECEF to geodetic conversion above, the conversion has no closed-form solution and approximate methods must be used. References such as the DMA Technical Manual 8358.1 and the USGS paper Map Projections: A Working Manual contain formulas for conversion of map projections. It is common to use computer programs to perform coordinate conversion tasks, such as with the DoD and NGA supported GEOTRANS program.

## Datum transformations

Transformations among datums can be accomplished in a number of ways. There are transformations that directly convert geodetic coordinates from one datum to another. There are more indirect transforms that convert from geodetic coordinates to ECEF coordinates, transform the ECEF coordinates from one datum to another, then transform ECEF coordinates of the new datum back to geodetic coordinates. There are also grid-based transformations that directly transform from one (datum, map projection) pair to another (datum, map projection) pair.

### Helmert transformation

Use of the Helmert transform in the transformation from geodetic coordinates of datum $A$ to geodetic coordinates of datum $B$ occurs in the context of a three-step process:
* Convert from geodetic coordinates to ECEF coordinates for datum $A$
* Apply the Helmert transform, with the appropriate $A\to B$ transform parameters, to transform from datum $A$ ECEF coordinates to datum $B$ ECEF coordinates
* Convert from ECEF coordinates to geodetic coordinates for datum $B$
In terms of ECEF XYZ vectors, the Helmert transform has the form (position vector transformation convention and very small rotation angles simplification)
    ${\begin{bmatrix}X_{B}\\Y_{B}\\Z_{B}\end{bmatrix}}={\begin{bmatrix}c_{x}\\c_{y}\\c_{z}\end{bmatrix}}+\left(1+s\times 10^{-6}\right){\begin{bmatrix}1&-r_{z}&r_{y}\\r_{z}&1&-r_{x}\\-r_{y}&r_{x}&1\end{bmatrix}}{\begin{bmatrix}X_{A}\\Y_{A}\\Z_{A}\end{bmatrix}}.$
The Helmert transform is a seven-parameter transform with three translation (shift) parameters $c_{x},\,c_{y},\,c_{z}$, three rotation parameters $r_{x},\,r_{y},\,r_{z}$ and one scaling (dilation) parameter $s$. The Helmert transform is an approximate method that is accurate when the transform parameters are small relative to the magnitudes of the ECEF vectors. Under these conditions, the transform is considered reversible.
A fourteen-parameter Helmert transform, with linear time dependence for each parameter,$^{:131-133}$ can be used to capture the time evolution of geographic coordinates dues to geomorphic processes, such as continental drift and earthquakes. This has been incorporated into software, such as the Horizontal Time Dependent Positioning (HTDP) tool from the U.S. NGS.

### Molodensky-Badekas transformation

To eliminate the coupling between the rotations and translations of the Helmert transform, three additional parameters can be introduced to give a new XYZ center of rotation closer to coordinates being transformed. This ten-parameter model is called the Molodensky-Badekas transformation and should not be confused with the more basic Molodensky transform.$^{:133-134}$
Like the Helmert transform, using the Molodensky-Badekas transform is a three-step process:
* Convert from geodetic coordinates to ECEF coordinates for datum $A$
* Apply the Molodensky-Badekas transform, with the appropriate $A\to B$ transform parameters, to transform from datum $A$ ECEF coordinates to datum $B$ ECEF coordinates
* Convert from ECEF coordinates to geodetic coordinates for datum $B$
The transform has the form
    ${\begin{bmatrix}X_{B}\\Y_{B}\\Z_{B}\end{bmatrix}}={\begin{bmatrix}X_{A}\\Y_{A}\\Z_{A}\end{bmatrix}}+{\begin{bmatrix}\Delta X_{A}\\\Delta Y_{A}\\\Delta Z_{A}\end{bmatrix}}+{\begin{bmatrix}1&-r_{z}&r_{y}\\r_{z}&1&-r_{x}\\-r_{y}&r_{x}&1\end{bmatrix}}{\begin{bmatrix}X_{A}-X_{A}^{0}\\Y_{A}-Y_{A}^{0}\\Z_{A}-Z_{A}^{0}\end{bmatrix}}+\Delta S{\begin{bmatrix}X_{A}-X_{A}^{0}\\Y_{A}-Y_{A}^{0}\\Z_{A}-Z_{A}^{0}\end{bmatrix}}.$
where $\left(X_{A}^{0},\,Y_{A}^{0},\,Z_{A}^{0}\right)$ is the origin for the rotation and scaling transforms and $\Delta S$ is the scaling factor.
The Molodensky-Badekas transform is used to transform local geodetic datums to a global geodetic datum, such as WGS 84. Unlike the Helmert transform, the Molodensky-Badekas transform is not reversible due to the rotational origin being associated with the original datum.$^{:134}$

### Molodensky transformation

The Molodensky transformation converts directly between geodetic coordinate systems of different datums without the intermediate step of converting to geocentric coordinates (ECEF). It requires the three shifts between the datum centers and the differences between the reference ellipsoid semi-major axes and flattening parameters.
The Molodensky transform is used by the National Geospatial-Intelligence Agency (NGA) in their standard TR8350.2 and the NGA supported GEOTRANS program. The Molodensky method was popular before the advent of modern computers and the method is part of many geodetic programs.

### Grid-based method

Grid-based transformations directly convert map coordinates from one (map-projection, geodetic datum) pair to map coordinates of another (map-projection, geodetic datum) pair. An example is the NADCON method for transforming from the North American Datum (NAD) 1927 to the NAD 1983 datum. The High Accuracy Reference Network (HARN), a high accuracy version of the NADCON transforms, have an accuracy of approximately 5 centimeters. The National Transformation version 2 (NTv2) is a Canadian version of NADCON for transforming between NAD 1927 and NAD 1983. HARNs are also known as NAD 83/91 and High Precision Grid Networks (HPGN). Subsequently, Australia and New Zealand adopted the NTv2 format to create grid-based methods for transforming among their own local datums.
Like the multiple regression equation transform, grid-based methods use a low-order interpolation method for converting map coordinates, but in two dimensions instead of three. The NOAA provides a software tool (as part of the NGS Geodetic Toolkit) for performing NADCON transformations.

### Multiple regression equations

Datum transformations through the use of empirical multiple regression methods were created to achieve higher accuracy results over small geographic regions than the standard Molodensky transformations. MRE transforms are used to transform local datums over continent-sized or smaller regions to global datums, such as WGS 84. The standard NIMA TM 8350.2, Appendix D, lists MRE transforms from several local datums to WGS 84, with accuracies of about 2 meters.
The MREs are a direct transformation of geodetic coordinates with no intermediate ECEF step. Geodetic coordinates $\phi _{B},\,\lambda _{B},\,h_{B}$ in the new datum $B$ are modeled as polynomials of up to the ninth degree in the geodetic coordinates $\phi _{A},\,\lambda _{A},\,h_{A}$ of the original datum $A$. For instance, the change in $\phi _{B}$ could be parameterized as (with only up to quadratic terms shown)$^{:9}$
    $\Delta \phi =a_{0}+a_{1}U+a_{2}V+a_{3}U^{2}+a_{4}UV+a_{5}V^{2}+\cdots$
where
    $a_{i},$ parameters fitted by multiple regression
    ${\begin{aligned}U&=K(\phi _{A}-\phi _{m})\\V&=K(\lambda _{A}-\lambda _{m})\\\end{aligned}}$
    $K,$ scale factor
    $\phi _{m},\,\lambda _{m},$ origin of the datum, $A.$
with similar equations for $\Delta \lambda$ and $\Delta h$. Given a sufficient number of $(A,\,B)$ coordinate pairs for landmarks in both datums for good statistics, multiple regression methods are used to fit the parameters of these polynomials. The polynomials, along with the fitted coefficients, form the multiple regression equations.