Convert GPS Coordinates to XYZ: The Earth-Centered System, Explained With Worked Examples
By the Osm4People editorial team
Photo: Zelch Csaba / Pexels
Sooner or later, anyone who works with GPS data meets a file where locations are not latitude and longitude but three big numbers, in the millions, labeled X, Y, and Z. Satellite software, robotics, aviation, 3D globe engines, and some surveying exports all speak this language. It looks like a mistake until someone tells you the secret: the origin, the zero point of the whole system, is the center of the Earth. This guide explains the system properly, in beginner language, then does the conversion in the open with real numbers, so that the next time an XYZ file lands on your desk you can read it, check it, and convert your own coordinates into it.
One honest note, following this site's habit: the converter on this page converts between latitude and longitude formats, and it does not compute XYZ. That is fine, because XYZ conversion is a formula, not a mystery, and this article gives you the formula, the constants, and verified worked examples to test any dedicated tool against. A tool you have checked against known answers is worth ten tools you have not.
Interactive tool
Coordinate Converter: Verify the Pair Before You Convert It
Every XYZ calculation starts from a clean latitude and longitude. Check your pair here in decimal degrees, DMS, and DDM first, then run the formulas in this article with confidence.
From decimal degrees
Degrees minutes seconds40° 41' 21.00" N, 74° 02' 40.00" W
Degrees decimal minutes40° 41.350' N, 74° 02.667' W
Plus code (11 digits)87G7MXQ4+M67
Plus code (10 digits)87G7MXQ4+M6
Your latitude breaks down as 40 degrees, 41 minutes, 21.00 seconds. One degree is 60 minutes, one minute is 60 seconds, so a second of latitude is about 31 meters on the ground.
From degrees minutes seconds
Decimal degrees40.689167, -74.044444
Degrees decimal minutes40° 41.350' N, 74° 02.667' W
Plus code (11 digits)87G7MXQ4+M67
Conversions use the WGS 84 coordinate system, the same one GPS satellites and phone maps use. Plus codes are computed with the open location code algorithm, the same method Google Maps uses.
What XYZ Means: The ECEF Frame
ECEF stands for Earth-Centered, Earth-Fixed, and each word earns its place. Earth-Centered: the origin (0, 0, 0) is the Earth's center of mass. Earth-Fixed: the axes rotate with the Earth, so a point on the ground keeps the same XYZ values all day, unlike a frame fixed to the stars, in which your house would sweep out a circle every 24 hours. The three axes are defined as follows:
X axis: points from the center out through the equator at the Prime Meridian, longitude 0. It exits the Earth in the Gulf of Guinea, off West Africa.
Y axis: points from the center out through the equator at longitude 90 east. It exits south of Sri Lanka, in the Indian Ocean.
Z axis: points from the center out through the North Pole.
Every position on Earth is then three distances, in meters, measured along those axes. Picture standing in a room whose floor center is the Earth's core: X is how far toward the Greenwich wall, Y toward the 90-east wall, Z toward the ceiling pole. The numbers are huge because the Earth is huge: surface points sit about 6.37 million meters from the center, so every XYZ coordinate of a real place is a number in the millions, positive or negative depending on which side of the center it lies. Negative values are normal and expected; the Sydney Opera House has two of them, as the worked examples below show.
The Constants and the Formulas
The conversion assumes an ellipsoid model of the Earth, and for GPS work that model is WGS 84, defined by two constants:
a = 6,378,137 m, the semi-major axis, the distance from the center to the equator.
1/f = 298.257223563, the inverse flattening. From it comes the polar radius, about 6,356,752.3 m, which is why the North Pole's Z below is smaller than the equator's X: the Earth is squashed by about 21.4 km at the poles.
Given latitude (φ), longitude (λ), and ellipsoidal height (h), first compute the radius of curvature in the prime vertical:
N = a / sqrt(1 - e² sin²φ), where e² = f(2 - f) ≈ 0.00669438.
Then the three coordinates fall out:
X = (N + h) cos φ cos λ
Y = (N + h) cos φ sin λ
Z = ((1 - e²) N + h) sin φ
Three warnings belong with the formulas, because each one is a real-world error with a body count of ruined datasets. First, h is ellipsoidal height, not altitude above sea level. GPS receivers report ellipsoidal height natively; maps and pilots use sea level height (orthometric), and the two differ by the geoid separation, which ranges across tens of meters depending where you stand. Feeding sea level height into these formulas puts your point tens of meters too high or low along the local vertical. Second, angles must be in radians in most software, or degrees in a calculator that expects degrees; mixing them is the classic silent failure. Third, latitude here is geodetic latitude, the kind GPS gives you, which is what every consumer coordinate already is, so this warning only matters if you meet geocentric latitude in astronomy-flavored sources.
Earth seen from space, the object whose center is the origin of every XYZ coordinate
Worked Examples, Computed From the Constants
Each example below was computed with the formulas above at ellipsoidal height h = 0, so you can reproduce or check them exactly. The first two are the sanity anchors every converter should be tested against.
Place
Latitude
Longitude
X (m)
Y (m)
Z (m)
Equator at Prime Meridian
0
0
6,378,137.0
0.0
0.0
North Pole
90
0
0.0
0.0
6,356,752.3
Mid-latitude anchor
45
0
4,517,590.9
0.0
4,487,348.4
Statue of Liberty
40.689167
-74.044444
1,331,345.9
-4,656,584.3
4,136,310.6
Eiffel Tower
48.858222
2.2945
4,200,950.7
168,323.7
4,780,200.0
Sydney Opera House
-33.856784
151.215297
-4,646,969.4
2,553,077.6
-3,533,265.7
Read the table as a set of stories. The equator point is pure X, the definition of the axis made visible. The North Pole is pure Z, and smaller, the polar squash in a single number. The mid-latitude anchor at 45 degrees shows X and Z nearly balanced, with Z a little smaller because of the (1 - e²) factor, and it agrees with published ECEF converter outputs for that input, which is exactly the kind of cross-check you should demand. The Statue of Liberty has a strongly negative Y because New York is far west of the 90-east axis direction, measured the other way around the globe. Sydney is negative in X and Z: it is on the opposite side of the center from Greenwich and in the southern hemisphere. If a converter gives you Sydney with a positive Z, it has lost a sign, and now you know enough to catch it.
Going Backwards: XYZ to Latitude and Longitude
The reverse trip has no tidy closed formula, and knowing why builds real understanding. Longitude is easy: it is the angle of the X-Y shadow of your point, λ = atan2(Y, X), one step. Latitude is tangled because the ellipsoid's surface normal, the direction latitude is measured from, does not pass through the center, so the formulas must be solved by iteration: guess a latitude, compute N and a height, recompute the latitude from the guess, and repeat three or four times until the answer stops moving. A classical shortcut by Bowring gets there in essentially one step and is what most software uses internally. For the reader, the practical summary is: forward is arithmetic, backward is iteration, and every serious library (PROJ, GeographicLib) does the backward direction to sub-millimeter consistency, so use a library or a checked tool rather than hand-rolling it. If your data flows through QGIS, our guide to adding GPS coordinates to QGIS shows the import side, and QGIS itself reprojects between systems, including geocentric ones, once the data is in.
Where You Will Meet XYZ in the Wild
Satellite orbit files and GNSS processing software live in ECEF because satellite physics prefers a center-of-Earth frame. Robotics and drone ground stations convert to it as an intermediate step, because distances and rotations are simpler in honest 3D meters than in degrees that change length with latitude (the problem our latitude and longitude questions and answers page quantifies). Game and globe engines place their worlds in XYZ for the same reason. And surveyors meet it whenever a total station or a GNSS base station exports "geocentric" coordinates. In every case the handling rules are the same: confirm the datum is WGS 84 (an ECEF triple in another datum is a different triple), confirm the units are meters, and test the converter you use against the equator and pole anchors in the table above before trusting it with data you care about. If your work is really about flat grids rather than the globe's center, the systems surveyors draw plans in are covered by our guides to UTM conversion and State Plane coordinates.
Units, Datums, and How Precise to Be
Three closing disciplines separate careful XYZ work from numerology. Units: ECEF values are in meters by definition in every GPS context; if a file's values look like the table above divided by about 3.28, someone has converted to feet, and the file must say so or it is a trap. Datum: an XYZ triple is meaningless without its datum, because the frame is anchored to a specific Earth model; WGS 84 is the near-universal default, but regional datums have their own ECEF realizations, and mixing them reintroduces exactly the meter-level shifts the State Plane guide warns about in its NAD83 discussion. Precision: quote XYZ to the millimeter (three decimals) for survey-flavored work and to the centimeter for ordinary conversions; more decimals than that describe the noise in your measurement, not the Earth. And keep the unrounded values in the file even when you display rounded ones, because round-tripping latitude to XYZ and back is the cheapest integrity check in this whole family of conversions, and rounding early quietly breaks it.
Related Guides
Readers working through this topic usually need its closest companions too. These coordinates guides cover the neighboring ground:
What does ECEF stand for and how is it different from XYZ?
They are the same thing said two ways. ECEF (Earth-Centered, Earth-Fixed) is the name of the coordinate frame; X, Y, and Z are its three axes. When a file or program says XYZ coordinates in a GPS context, it almost always means ECEF values in meters from the Earth's center, with X through the equator at Greenwich, Y through the equator at 90 east, and Z through the North Pole.
Why are XYZ coordinates in the millions?
Because they are distances from the center of the Earth, and the Earth's radius is about 6,371 km on average. Any point on the surface is roughly 6.37 million meters from the origin, split among the three axes according to its latitude and longitude. Small values would be the suspicious ones: an XYZ triple in the thousands describes a point deep inside the planet.
Can XYZ coordinates be negative?
Yes, and most places have at least one negative axis value. Negative X means the point is on the far side of the center from Greenwich's hemisphere of the equator plane; negative Y means west of the 90-east meridian's half; negative Z means southern hemisphere. The Sydney Opera House example in this article has negative X and Z. A converter that returns all-positive values for a southern, far-eastern city has made a sign error.
What height should I use in the conversion?
Ellipsoidal height: the height above the WGS 84 ellipsoid surface, which is what GPS receivers natively measure. Do not substitute elevation above sea level without correcting for the geoid, because the two heights differ by tens of meters in many regions, and the error lands directly in your XYZ values. If you only know sea level height, treat the result as approximate by that same margin. Our explainer on what elevation is untangles the height systems.
How do I convert XYZ back to latitude and longitude?
Longitude comes from one arctangent of Y over X. Latitude and height need iteration or the Bowring shortcut, because latitude is measured from the ellipsoid's surface normal, which does not pass through the center. In practice, use a checked tool or library such as PROJ rather than deriving it by hand, and verify it by round-tripping one of the worked examples in this article: convert the Statue of Liberty's XYZ back and demand 40.689167, -74.044444 at the end.
Is XYZ the same as UTM or State Plane?
No. UTM and State Plane are flat, two-dimensional grid systems measured in meters or feet from a local origin on the surface, made for maps and plans. XYZ is the full three-dimensional frame centered inside the Earth. The same point has all three addresses; they answer different questions, and confusing a six-digit grid value with a seven-digit geocentric value is a data error this article's tables are designed to help you spot.
Photo credits: Zelch Csaba (Pexels); Zelch Csaba (Pexels). Photos are served from this site; follow the credit to the library page for the original.