# Coordinates conversion

Note: This document is available in PDF.

## Introduction

Coordinate conversion between Universal Transverse Mercator (UTM) and geographic coordinates is a very common problem when working with Geographic Information Systems.

This document is an English translation of a publication that is in Spanish  . I use that method for coding my own program to convert coordinates.

There are some procedures to perform the conversion between geographic coordinates and UTM.

• UTM Projection tables, from Servicio Geográfico del Ejército de España (SGE), Sección de Geodesia (1976): Proyección Universal Tranversa Mercator, SGE, Madrid. Vol. I: Sistemas conformes. Proyección U.T.M. Cuadrículas y Sistemas de referencia, (220 pp.); Vol. II: Tablas, (331 pp.).
• US Army direct formulas for transformation, published in 1973 (USGS Bolletin No. 1532).
• Coticchia-Surace formulas, from “Bolletino di Geodesia a Science Affini” No. 1.

This document is using the third method which is the easiest to code in a computer program. This procedure gets centimeter precision in the conversion if using enough decimal places, so floating point or double variables should be used.

## Conversion from geographic coordinates to UTM

First we get a pair of geodesic geographic coordinates and the basic data of Hayford ellipsoid (as an example but you can use other ellipsoid), such as semi-major axis $$(a)$$ and semi-minor axis $$(b)$$.

\begin{equation}
b = 6,356,911.94613
\end{equation}

With this data we can start the operations.

### Previous calculations

#### Ellipsoid geometry

We start to calculate the eccentricity, second eccentricity, polar radius of curvature and flattening. Eccentricity ((e)) and second eccentricity ((e’)) are given by:

\begin{equation}
e = \frac{\sqrt{a^2 – b^2}}{a}
\end{equation}

\begin{equation}
e’ = \frac{\sqrt{a^2 – b^2}}{b}
\end{equation}

The square of the second eccentricity is a very useful number in the operations so make sure to save it somewhere. The polar radius of curvature ((c)) and flattening ((\alpha)) are given by:

\begin{equation}
c = \frac{a^2}{b}
\end{equation}

\begin{equation}
\alpha = \frac{a-b}{a}
\end{equation}

Actually the flattening and eccentricity aren’t necessary for the Coticchia-Surace equations, but they are frequent parameters of the ellipsoid that sometimes are given as a pair of data ((a)) and ((\alpha)); and sometimes as ((a)) and ((e)). Under those circumstances one can calculate ((b)) if the corresponding equations are known.

#### Latitude and longitude

First, sexagesimal degrees (or degrees, minutes and seconds represented as ((DD), (MM) and (SS)) have to be converted to decimal notation.

\begin{equation}
dec = DD + \frac{MM}{60} + \frac{SS}{3600}
\end{equation}

Once we have latitude ((\varphi)) and longitude ((\lambda)) in decimal notation, they have to be converted to radians. The operation is as follow

\begin{equation}
\end{equation}

Next, the longitude sign should be determined. This is as simple as

\begin{equation}
sign \left{ \begin{array}{l}
\text{If West, then negative (-)} \
\text{If East, then positive (+)}
\end{array} \right.
\end{equation}

West and East are the longitude referenced from the Greenwich meridian.

#### Time zone

Once we have longitude and latitude ready, the time zone or UTM zone where the coordinates are located can be obtained.

\begin{equation}
zone = int \left[\frac{dec}{6} + 31\right]
\end{equation}

Where (int) represent only the integer part of the obtained value.

Next step is to get the central meridian of such time zone.

\begin{equation}
\lambda_0 = zone \cdot 6 – 183
\end{equation}

Following we have to calculate the distance between the longitude of our original coordinates and the central meridian. Its important to notice that this operations have to be done in radians, so the central meridian just obtained have to be converted first. The original longitude is already in radians.

\begin{equation}
\Delta \lambda = \lambda – \lambda_0
\end{equation}

### Coticchia-Surace equations

In this section the Coticchia-Surace equations for the direct problem of converting geodesic geographic coordinates to UTM are presented.

#### Parameter calculation

A set of serial parameters should be calculated. There are a lot of equations but they are sequential and easy to code.

\begin{equation}
A = \cos \varphi \cdot \sin \Delta \lambda
\end{equation}

\begin{equation}
\xi = \frac{1}{2} \cdot \ln \left[ \frac{1+A}{1-A} \right]
\end{equation}

\begin{equation}
\eta = \arctan \left( \frac{\tan \varphi}{cos \Delta \lambda} \right) – \varphi
\end{equation}

\begin{equation}
\nu = \frac{c}{(1 + e’^2 \cdot \cos^2 \varphi)^\frac{1}{2}} \cdot 0.9996
\end{equation}

where (0.9996) is the scale factor for the UTM projection.

\begin{equation}
\zeta = \frac{e’^2}{2} \cdot \xi^2 \cdot \cos^2 \varphi
\end{equation}

\begin{equation}
A_1 = \sin (2 \cdot \varphi)
\end{equation}

\begin{equation}
A_2 = A_1 \cdot \cos^2 \varphi
\end{equation}

\begin{equation}
J_2 = \varphi + \frac{A_1}{2}
\end{equation}

\begin{equation}
J_4 = \frac{3 \cdot J_2 + A_2}{4}
\end{equation}

\begin{equation}
J_6 = \frac{5 \cdot J_4 + A_2 \cos^2 \varphi}{3}
\end{equation}

\begin{equation}
\alpha = \frac{3}{4} \cdot e’^2
\end{equation}

\begin{equation}
\beta = \frac{5}{3} \cdot \alpha^2
\end{equation}

\begin{equation}
\gamma = \frac{35}{27} \cdot \alpha^3
\end{equation}

\begin{equation}
B_\phi = 0.9996 \cdot c \cdot (\varphi – \alpha J_2 + \beta J_4 – \gamma J_6)
\end{equation}

Final calculation of coordinates
Once we have all the parameters the final coordinates in UTM is obtained as follow

\begin{equation}
X = \xi \cdot \nu \cdot \left( 1 + \frac{\zeta}{3} \right) + 500,000
\end{equation}

For the (Y) solution is important to remember if the latitude of the geodesic geographic coordinates belongs to the southern hemisphere, we should add the value of (10,000,000) to the result. In the case of northern hemisphere we have nothing to add.

\begin{equation}
Y = \eta \cdot \nu \cdot \left( 1 + \zeta \right) + B_\phi
\end{equation}

## Conversion from UTM to geographic coordinates

We are going to start by using a pair of UTM coordinates and their respective zone. Also we are going to need the basic data of Hayford ellipsoid (as an example but you can use another ellipsoid), such as semi-major axis ((a)) and semi-minor axis ((b)).

\begin{equation}
b = 6,356,911.94613
\end{equation}

With this data we can start the operations. The ellipsoid geometry calculations are exactly the same as the previous section, the parameter calculations are very similar.

### Previous calculations

#### Ellipsoid geometry

We start to calculate the eccentricity, second eccentricity, polar radius of curvature and flattening. Eccentricity ((e)) and second eccentricity ((e’)) are given by:

\begin{equation}
e = \frac{\sqrt{a^2 – b^2}}{a}
\end{equation}

\begin{equation}
e’ = \frac{\sqrt{a^2 – b^2}}{b}
\end{equation}

The square of the second eccentricity is a very useful number in the operations so make sure to save it somewhere. The polar radius of curvature ((c)) and flattening ((\alpha)) are given by:

\begin{equation}
c = \frac{a^2}{b}
\end{equation}

\begin{equation}
\alpha = \frac{a-b}{a}
\end{equation}

Actually the flattening and eccentricity aren’t necessary for the Coticchia-Surace equations, but they are frequent parameters of the ellipsoid that sometimes are given as a pair of data ((a)) and ((\alpha)); and sometimes as ((a)) and ((e)). Under those circumstances one can calculate ((b)) if the corresponding equations are known.

Previous calculations of (X, Y) coordinates
We start by modifying the X coordinate

\begin{equation}
X = X – 500,000
\end{equation}

For the Y coordinate we should modify it only when it is on the southern hemisphere

\begin{equation}
sign \left{ \begin{array}{l}
\text{If Northern, then not modify Y} \
\text{If Southern, then Y = Y – 10,000,000}
\end{array} \right.
\end{equation}

Central meridian of the time zone
The UTM zone of the X,Y coordinates to convert should be known as another parameter in the conversion. This operation is similar to the inverse conversion

\begin{equation}
\lambda_0 = zone \cdot 6 – 183
\end{equation}

### Coticchia-Surace equations

#### Parameter calculations

Most of the parameters are calculated in a similar way or even equal to the previous problem

\begin{equation}
\varphi’ = \frac{Y}{6,366,197.724 \cdot 0.9996}
\end{equation}

\begin{equation}
\nu = \frac{c}{(1 + e’^2 \cdot \cos^2 \varphi’)^\frac{1}{2}} \cdot 0.9996
\end{equation}

\begin{equation}
a = \frac{X}{\nu}
\end{equation}

\begin{equation}
A_1 = \sin (2 \cdot \varphi’)
\end{equation}

\begin{equation}
A_2 = A_1 \cdot \cos^2 \varphi’
\end{equation}

\begin{equation}
J_2 = \varphi’ + \frac{A_1}{2}
\end{equation}

\begin{equation}
J_4 = \frac{3 \cdot J_4 + A_2}{4}
\end{equation}

\begin{equation}
J_6 = \frac{5 \cdot J_4 + A_2 \cdot \cos^2 \varphi’}{3}
\end{equation}

\begin{equation}
\alpha = \frac{3}{4} \cdot e’^2
\end{equation}

\begin{equation}
\beta = \frac{5}{4} \cdot \alpha^2
\end{equation}

\begin{equation}
\gamma = \frac{35}{27} \cdot \alpha^3
\end{equation}

\begin{equation}
B_\phi = 0.9996 \cdot c \cdot \left( \varphi’ – \alpha \cdot J_2 + \beta \cdot J_4 – \gamma \cdot J_6 \right)
\end{equation}

\begin{equation}
b = \frac{Y – B_\phi}{\nu}
\end{equation}

\begin{equation}
\zeta = \frac{e’^2 \cdot a^2}{2} \cdot \cos^2 \varphi’
\end{equation}

\begin{equation}
\xi = a \cdot \left[ 1 – \frac{\zeta}{3} \right]
\end{equation}

\begin{equation}
\eta = b \cdot (1 – \zeta) + \varphi’
\end{equation}

\begin{equation}
\sin h \xi = \frac{\exp^\xi – \exp^{-\xi}}{2}
\end{equation}

\begin{equation}
\Delta \lambda = \arctan \frac{\sin h \xi}{\cos \eta}
\end{equation}

\begin{equation}
\tau = \arctan (\cos \Delta \lambda \cdot \tan \eta)
\end{equation}

### Final calculation of coordinates

The longitude composition is very simple. We have to take care of performing this operation in degrees expressed in decimal notation, so (\Delta \lambda) has to be divided by (\pi) and multiplied by (180). (\lambda_0) is already in decimal degrees\begin{equation}
\lambda = \Delta \lambda + \lambda_0
\end{equation}

The latitude calculation is a little more complicated:

\begin{equation}
\begin{array}{l l}
\varphi = & \varphi’ + \left[ 1 + e’^2 \cdot \cos^2 \varphi’ -\frac{3}{2} \cdot e’^2 \cdot \sin \varphi’ \cdot \right. \
& \left. \cos \varphi’ \cdot (\tau – \varphi’) \right] \cdot (\tau – \varphi’)
\end{array}
\end{equation}

Now we have to convert the latitude from radians to degrees expressed in decimal notation

\begin{equation}
dec = \frac{\varphi (\text{in radians)}}{\pi} \cdot 180
\end{equation}

Once we have latitude and longitude in degrees expressed in decimal notation, we have to convert the result to sexagesimal notation in degrees, minutes and seconds ((DD, MM, SS)). For the degrees we operate both latitude and longitude as follow

\begin{equation}
DD = int[dec]
\end{equation}

where (int) is the integer part of the value. Then minutes

\begin{equation}
MM = int[(dec – DD) \cdot 60]
\end{equation}

again (int) is the integer part of the value. Finally, seconds

\begin{equation}
SS = ((dec – DD) \cdot 60 – MM) \cdot 60
\end{equation}

If longitude result with negative sign then the value its at west of Greenwich meridian.