Lat/Lng to ECEF Converter

Convert WGS-84 lat/long/altitude to ECEF Cartesian XYZ

Convert WGS-84 geodetic coordinates (latitude, longitude, ellipsoidal height) into Earth-Centered Earth-Fixed (ECEF) Cartesian X, Y, Z metres using the exact prime-vertical radius formula. Free, instant, browser-based. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

What is ECEF?

Earth-Centered, Earth-Fixed (ECEF) is a 3-D Cartesian system whose origin is the Earth's centre of mass. The Z axis points to the North Pole, X points to the equator/prime-meridian intersection, and Y completes the right-handed frame.

WGS-84 geodetic to ECEF

This converter turns a geographic position — latitude, longitude and ellipsoidal height — into Earth-Centered Earth-Fixed (ECEF) Cartesian coordinates. ECEF is the frame used internally by GPS receivers, satellite tracking, and many geodetic computations because it expresses a point as plain X, Y, Z metres relative to the centre of the Earth.

How it works

The transform is closed-form. First compute the prime-vertical radius of curvature N at the given latitude:

N = a / sqrt(1 - e^2 * sin^2(lat))

where a = 6378137 m (WGS-84 semi-major axis) and e^2 = f(2 - f) is the first eccentricity squared from the flattening f = 1/298.257223563. Then:

X = (N + h) * cos(lat) * cos(lon)
Y = (N + h) * cos(lat) * sin(lon)
Z = (N * (1 - e^2) + h) * sin(lat)

with latitude and longitude in radians and h the ellipsoidal height in metres. The (1 - e^2) factor on Z accounts for the Earth being an oblate spheroid rather than a sphere.

Why ECEF is useful

ECEF strips away the curvilinear coordinate system and gives you a flat 3D space. This makes several computations straightforward that would be complicated in latitude/longitude:

Straight-line distance between two points is just the Euclidean distance between their ECEF vectors — no great-circle formula needed. This works when the distance is small enough that the Earth’s curvature does not matter for your purpose (typically up to a few hundred kilometres).

Relative position in a local frame — subtracting two ECEF vectors gives a displacement in Earth-fixed Cartesian space, which is the starting point for converting to local East-North-Up (ENU) or North-East-Down (NED) frames used in inertial navigation.

Satellite geometry — GPS pseudorange equations are written in ECEF. Satellite positions are broadcast in ECEF, and receiver positions are solved in ECEF before being converted to geodetic coordinates for display.

3D rotation and simulation — physics engines, orbital mechanics, and antenna pointing calculations all work naturally in Cartesian space.

Ellipsoidal vs orthometric height

The most common input mistake is confusing ellipsoidal height (h, the height above the WGS-84 mathematical ellipsoid) with orthometric height (H, the height above mean sea level as shown on most topographic maps and GPS displays).

The difference between them is the geoid undulation N: h = H + N

This undulation varies globally from about −106 m (near Indonesia) to +85 m (near Iceland). In Paris it is around +44 m, so a sea-level elevation of 0 m corresponds to an ellipsoidal height of +44 m. GPS receivers typically output the ellipsoidal height, but some display or log the orthometric height after applying a geoid model. Check which one you have before entering it here.

Example and notes

For example, a point at roughly 48.8584° N, 2.2945° E, 330 m ellipsoidal height gives X ≈ 4,200,952 m, Y ≈ 168,386 m, Z ≈ 4,780,740 m. The transform is exact in the forward direction; converting back to latitude and longitude requires an iterative or Bowring-style solution because latitude appears inside the N formula.