A Greek survey, cadastral plan or engineering drawing gives you coordinates like E = 476 000.00 m, N = 4 203 000.00 m. A GPS receiver, Google Maps or OpenStreetMap expect something completely different: latitude and longitude in degrees. Getting from one to the other looks like a single conversion, but it is really two different problems stacked on top of each other: undoing a map projection, and moving from one geodetic datum to another. This article walks through the maths behind both, with a worked example, a short Python implementation, and an honest look at why the simple 3-parameter shift is only an approximation.
Two problems in one: projection and datum
EGSA87 (in English GGRS87, the Greek Geodetic Reference System 1987) is both a datum and, in its projected form, a grid:
- the datum fixes where the GRS80 ellipsoid sits relative to the Earth. GGRS87 was tied to the Earth by an orientation at the Dionysos observatory near Athens, and its ellipsoid is not centred on the Earth's centre of mass;
- the grid ("Greek Grid", EPSG:2100) is a transverse Mercator projection of that ellipsoid with central meridian $24^\circ$ E, scale factor $k_0 = 0.9996$, false easting $500\,000$ m and false northing $0$.
WGS84 (EPSG:4326) is the geocentric datum used by GPS, with coordinates given as geographic latitude $\varphi$ and longitude $\lambda$ on the WGS84 ellipsoid. The two ellipsoids are almost identical: they share the semi-major axis $a = 6\,378\,137$ m and differ only in the flattening, $1/f = 298.257222101$ for GRS80 against $298.257223563$ for WGS84. That difference moves a point by only about a tenth of a millimetre, so for practical work the ellipsoids can be treated as the same. The real difference between the datums is where the ellipsoid is centred and how it is oriented.
The pipeline
The conversion has four steps. Only the third one changes the datum; the others merely change the way the same position is written down.
Step 1: undoing the transverse Mercator projection
The grid coordinates $(E, N)$ are first turned back into latitude and longitude on the GRS80 ellipsoid. With the flattening $f$ and the semi-major axis $a$, define the third flattening and the rectifying radius
and scale the grid offsets to dimensionless numbers (with $E_0 = 500\,000$ m and $N_0 = 0$):
The Krüger series then gives the conformal latitude $\chi$ and the longitude difference from the central meridian:
The coefficients are small polynomials in $n$; the leading terms are $\beta_1 = \tfrac{n}{2} - \tfrac{2n^2}{3} + \dots$ and $\delta_1 = 2n - \tfrac{2n^2}{3} - \dots$ (all four orders are in the code below). Truncating at fourth order keeps the error below a millimetre across Greece. Older textbooks use equivalent series in the meridian arc length (Snyder, Redfearn); the method is a matter of taste, the result is the same.
Step 2: from latitude and longitude to geocentric X, Y, Z
A datum shift is a 3D operation, so the geodetic coordinates $(\varphi, \lambda, h)$ are converted to Cartesian coordinates whose origin is the centre of the ellipsoid. With $e^2 = f(2-f)$ and the prime vertical radius of curvature $\nu = a / \sqrt{1 - e^2\sin^2\varphi}$:
For a point read off a map the height $h$ is taken as $0$ on the GRS80 ellipsoid.
Step 3: the Helmert transformation
Two geocentric frames that describe the same Earth differ, to a very good approximation, by a rigid-body motion plus a tiny change of scale. That is the seven-parameter Helmert (similarity) transformation: three translations $(t_x, t_y, t_z)$, three small rotations $(r_x, r_y, r_z)$ and one scale factor $s$. In the position-vector convention:
Here the rotations are in radians (one arc-second is $4.848\times10^{-6}$ rad) and $s$ is a dimensionless number, normally quoted in parts per million. The rotation matrix is the small-angle approximation, which is more than accurate enough because the angles are fractions of an arc-second.
The 3-parameter shift is the special case $r_x = r_y = r_z = s = 0$: the two frames are assumed to have parallel axes and the same scale, differing only by the position of the origin:
Step 4: back to latitude and longitude
The shifted point $(X', Y', Z')$ is converted back to geodetic coordinates on the WGS84 ellipsoid. There is no closed form, but a short fixed-point iteration converges in three or four steps:
Notice that the output also contains an ellipsoidal height $h'$. After the shift the point no longer lies on the surface of the (displaced) ellipsoid: in the example below it comes out about $31$ m above the WGS84 ellipsoid. A converter that works only in two dimensions and skips the geocentric step cannot reproduce this, which is why a simple "add a constant to the latitude and longitude" does not work: the shift in degrees is different in every part of the country.
A worked example
Take a point in the centre of Athens, $E = 476\,000.00$ m, $N = 4\,203\,000.00$ m, and the 3-parameter set used by the converter, $\Delta X = -199.72$ m, $\Delta Y = +74.03$ m, $\Delta Z = +246.02$ m:
| Step | Result |
|---|---|
| 1. Inverse TM (GRS80) | $\varphi = 37.974311059^\circ$, $\lambda = 23.726738712^\circ$ |
| 2. Geocentric (GRS80) | $X = 4\,608\,669.435$, $Y = 2\,025\,630.174$, $Z = 3\,903\,196.660$ m |
| 3. After the shift | $X' = 4\,608\,469.715$, $Y' = 2\,025\,704.204$, $Z' = 3\,903\,442.680$ m |
| 4. WGS84 geodetic | $\varphi' = 37.976906692^\circ$, $\lambda' = 23.728424738^\circ$, $h' = 30.738$ m |
The datum shift moved the point by about $0.0026^\circ$ in latitude and $0.0017^\circ$ in longitude: roughly $290$ m north and $150$ m east. That is the size of the difference you would see between a map plotted in the wrong datum and the right one.
Why a 3-parameter shift is not enough
The 3-parameter shift is popular because it needs no more than three numbers and is easy to implement. For navigation and mapping it is perfectly adequate: EPSG lists the standard set for Greece, $(-199.87, +74.79, +246.62)$ m (EPSG:1272), with a stated accuracy of about one metre. But it rests on three assumptions that real datums do not quite satisfy.
1. The axes are not exactly parallel
A rotation of one arc-second corresponds to $4.848\times10^{-6} \times 6\,371\,000\ \text{m} \approx 31$ m on the Earth's surface. Rotations in real datum relationships are fractions of an arc-second, but even a tenth of an arc-second matters. The table shows what happens at the Athens point above when one parameter is changed while all the others stay fixed (these are sensitivities, not real error figures):
| Parameter changed | Horizontal shift | Height change |
|---|---|---|
| $r_x = 0.1''$ | 2.1 m | 0.004 m |
| $r_y = 0.1''$ | 2.9 m | −0.009 m |
| $r_z = 0.1''$ | 2.4 m | 0.000 m |
| $s = 1$ ppm | 0.02 m | 6.37 m |
Ignoring a rotation of just $0.1''$ therefore costs two to three metres horizontally. A scale difference of 1 ppm is a $6.4$ m change in height, but hardly affects the horizontal position near the surface.
2. A parameter set describes a region, not the whole country
The parameters are fitted by least squares to points whose coordinates are known in both systems. Different point sets, regions and weights give slightly different numbers. The converter on this site uses $(-199.72, +74.03, +246.02)$ m, while EPSG:1272 gives $(-199.87, +74.79, +246.62)$ m. At the Athens point the two disagree by $0.76$ m east and $0.37$ m north, $0.84$ m in total, even though both are legitimate, published 3-parameter sets. With so few degrees of freedom, a 3-parameter set is a compromise: it cannot be right everywhere.
3. The datum is not a perfectly rigid network
GGRS87 was realised by a classical geodetic network observed in the 1980s. Such networks carry local distortions of decimetres up to a metre or more that no rigid-body model, however many parameters it has, can remove. For this reason the official Greek solution does not stop at seven parameters: the HEPOS positioning system, which provides coordinates in the modern HTRS07 frame (a realisation of ETRS89), combines a 7-parameter transformation with a correction grid on a 2 km × 2 km mesh, and is reported to reach about 8 cm rms over the whole of Greece (see the HEPOS presentation). The grid absorbs the residual distortions of the old network, point by point.
What this means in practice
| Use case | Is a 3-parameter shift enough? |
|---|---|
| Plotting survey points on a web map, navigation, GIS overview | Yes: about a metre is below what you can see. |
| Checking or comparing coordinates approximately | Yes, as long as you know the expected error is around a metre. |
| Cadastral boundaries, engineering set-out, GNSS surveys tied to HEPOS | No. Use the official HEPOS transformation (7 parameters plus grid), or software that implements it. |
The converter on this site is intended for the first two rows, and says so in its methodology note. For centimetre-level work, take the coordinates through the official tools.
Implementing it in Python
The whole pipeline fits in a few dozen lines of standard-library Python. The code below follows the four steps, uses the same parameters as the converter, and accepts optional rotations and scale so you can experiment with the sensitivities above.
import math
# Ellipsoids: semi-major axis a (m) and flattening f
GRS80 = (6378137.0, 1 / 298.257222101) # EGSA87 / GGRS87
WGS84 = (6378137.0, 1 / 298.257223563)
def tm_inverse(E, N, ell=GRS80, lon0=24.0, k0=0.9996, E0=500000.0, N0=0.0):
"""Inverse transverse Mercator (Kruger n-series): grid (E, N) -> geodetic (lat, lon) in degrees."""
a, f = ell
n = f / (2 - f)
A = a / (1 + n) * (1 + n**2 / 4 + n**4 / 64)
beta = [n / 2 - 2 * n**2 / 3 + 37 * n**3 / 96 - n**4 / 360,
n**2 / 48 + n**3 / 15 - 437 * n**4 / 1440,
17 * n**3 / 480 - 37 * n**4 / 840,
4397 * n**4 / 161280]
delta = [2 * n - 2 * n**2 / 3 - 2 * n**3 + 116 * n**4 / 45,
7 * n**2 / 3 - 8 * n**3 / 5 - 227 * n**4 / 45,
56 * n**3 / 15 - 136 * n**4 / 35,
4279 * n**4 / 630]
xi = (N - N0) / (k0 * A)
eta = (E - E0) / (k0 * A)
xi_p = xi - sum(b * math.sin(2 * j * xi) * math.cosh(2 * j * eta) for j, b in enumerate(beta, 1))
eta_p = eta - sum(b * math.cos(2 * j * xi) * math.sinh(2 * j * eta) for j, b in enumerate(beta, 1))
chi = math.asin(math.sin(xi_p) / math.cosh(eta_p))
lat = chi + sum(d * math.sin(2 * j * chi) for j, d in enumerate(delta, 1))
lon = math.radians(lon0) + math.atan2(math.sinh(eta_p), math.cos(xi_p))
return math.degrees(lat), math.degrees(lon)
def geodetic_to_xyz(lat, lon, h=0.0, ell=GRS80):
a, f = ell
e2 = f * (2 - f)
phi, lam = math.radians(lat), math.radians(lon)
nu = a / math.sqrt(1 - e2 * math.sin(phi) ** 2) # prime vertical radius
return ((nu + h) * math.cos(phi) * math.cos(lam),
(nu + h) * math.cos(phi) * math.sin(lam),
(nu * (1 - e2) + h) * math.sin(phi))
def xyz_to_geodetic(X, Y, Z, ell=WGS84):
a, f = ell
e2 = f * (2 - f)
p = math.hypot(X, Y)
lam = math.atan2(Y, X)
phi = math.atan2(Z, p * (1 - e2)) # first guess
for _ in range(10): # converges in 3-4 steps
nu = a / math.sqrt(1 - e2 * math.sin(phi) ** 2)
h = p / math.cos(phi) - nu
phi = math.atan2(Z, p * (1 - e2 * nu / (nu + h)))
return math.degrees(phi), math.degrees(lam), h
ARCSEC = math.pi / 648000 # 1 arc-second in radians
def helmert(X, Y, Z, t, r=(0.0, 0.0, 0.0), s_ppm=0.0):
"""7-parameter Helmert, position-vector convention. t in m, r in arc-seconds, s in ppm."""
rx, ry, rz = (v * ARCSEC for v in r)
k = 1 + s_ppm * 1e-6
return (t[0] + k * (X - rz * Y + ry * Z),
t[1] + k * (rz * X + Y - rx * Z),
t[2] + k * (-ry * X + rx * Y + Z))
def egsa87_to_wgs84(E, N, t=(-199.72, 74.03, 246.02), r=(0.0, 0.0, 0.0), s_ppm=0.0):
lat, lon = tm_inverse(E, N) # 1. grid -> GRS80 geodetic
X, Y, Z = geodetic_to_xyz(lat, lon) # 2. geodetic -> geocentric XYZ
X, Y, Z = helmert(X, Y, Z, t, r, s_ppm) # 3. datum shift
return xyz_to_geodetic(X, Y, Z) # 4. XYZ -> WGS84 geodetic
if __name__ == "__main__":
lat, lon, h = egsa87_to_wgs84(476000.0, 4203000.0)
print(f"lat = {lat:.9f}")
print(f"lon = {lon:.9f}")
print(f"h = {h:.3f} m")
Running it with the Athens point prints:
lat = 37.976906692
lon = 23.728424738
h = 30.738 m
I checked the implementation against the independent proj4js library using the same projection and parameters, and both agree to ten decimal places in degrees (a fraction of a millimetre). For production work, the standard library for this is PROJ. For example, with pyproj:
from pyproj import Transformer
t = Transformer.from_crs("EPSG:2100", "EPSG:4326", always_xy=True)
lon, lat = t.transform(476000.0, 4203000.0)
Note always_xy=True: without it, PROJ follows the axis order of the coordinate system definition, which for EPSG:4326 is latitude first. PROJ chooses the best operation it has data for, so depending on what is installed its result can differ from the converter's by up to about a metre.
Common mistakes
- Swapping latitude and longitude. Some tools use $(\varphi, \lambda)$, others $(x, y) = (\lambda, \varphi)$. Check the axis order before you plot.
- Mixing up easting and northing. In EGSA87, eastings are typically six-digit numbers (roughly $100\,000$ to $900\,000$ m) and northings seven-digit numbers (roughly $3.8$ to $4.7$ million m); if your numbers look the other way round, the columns are swapped.
- Degrees versus radians. Trigonometric functions need radians; the series above also expect $\xi, \eta$ in radians.
- Rounding in degrees–minutes–seconds. One second of latitude is about $31$ m. Keep full precision internally and round only for display.
- Using the wrong rotation convention when taking a 7-parameter set from a document (see the note in step 3).
- Applying the shift in 2D. The datum shift is a 3D operation; skipping the geocentric step gives errors of metres.
Summary
- EGSA87 to WGS84 is two conversions: undo the transverse Mercator projection, then change datum.
- The datum change is done in geocentric Cartesian coordinates with a Helmert transformation: seven parameters in general, three in the simplified form.
- A 3-parameter shift ignores rotation and scale, depends on the region it was fitted to, and cannot remove the distortions of the old network. Expect about a metre.
- For centimetre accuracy use the official HEPOS approach: 7 parameters plus a correction grid.
References
- EPSG Geodetic Parameter Dataset: GGRS87 to WGS 84 (1), EPSG:1272.
- C. F. F. Karney, "Transverse Mercator with an accuracy of a few nanometers", Journal of Geodesy 85 (2011), 475–485 (the Krüger series used above).
- Katsampalos, Kotsakis, Gianniou, HEPOS: the Hellenic Positioning System (transformation HTRS07 ↔ GGRS87).
- Hellenic Geodetic Reference System 1987, Wikipedia.