I am trying to convert an ECEF coordinate to a geodetic coordinate using this procedure, but I don't fully understand the process. It is prefaced by stating the geodetic parameters {a,b,e,e'} are assumed to be known, but does not state what they reference to.

I assume that a and b are the equatorial and polar semi-axes, and that e is just Euler's number. Am I correct in this? And what is e' supposed to be?

  • 1
    What software are you using? What have you tried so far?
    – MaryBeth
    Commented Dec 19, 2017 at 18:48
  • @MaryBeth I'm writing the conversion as a function in Java. I've researched a few different methods for converting ECEF to Geodetic (e.g. Zhu referenced by wikipedia), but this one is most easily translatable into Java code. I can't figure out what the known parameters are reference to though.
    – Derek S.
    Commented Dec 19, 2017 at 18:56

4 Answers 4


You can use this function to perform the conversion of ECEF coordinates to Geodetic coordinates.

The function is implemented in python but can be easily written in java.


import math

def xyz2llh(x,y,z):
    Function to convert xyz ECEF to llh
    convert cartesian coordinate into geographic coordinate
    ellipsoid definition: WGS84
      a= 6,378,137m
      f= 1/298.257

      x: coordinate X meters
      y: coordinate y meters
      z: coordinate z meters
      lat: latitude rad
      lon: longitude rad
      h: height meters
    # --- WGS84 constants
    a = 6378137.0
    f = 1.0 / 298.257223563
    # --- derived constants
    b = a - f*a
    e = math.sqrt(math.pow(a,2.0)-math.pow(b,2.0))/a
    clambda = math.atan2(y,x)
    p = math.sqrt(pow(x,2.0)+pow(y,2))
    h_old = 0.0
    # first guess with h=0 meters
    theta = math.atan2(z,p*(1.0-math.pow(e,2.0)))
    cs = math.cos(theta)
    sn = math.sin(theta)
    N = math.pow(a,2.0)/math.sqrt(math.pow(a*cs,2.0)+math.pow(b*sn,2.0))
    h = p/cs - N
    while abs(h-h_old) > 1.0e-6:
        h_old = h
        theta = math.atan2(z,p*(1.0-math.pow(e,2.0)*N/(N+h)))
        cs = math.cos(theta)
        sn = math.sin(theta)
        N = math.pow(a,2.0)/math.sqrt(math.pow(a*cs,2.0)+math.pow(b*sn,2.0))
        h = p/cs - N
    llh = {'lon':clambda, 'lat':theta, 'height': h}
    return llh

After some more research (from here and here), I believe e and e' refer to first and second eccentricity, while a and b do indeed refer to the equatorial and polar semi-axes. Hopefully somebody can confirm this, as I am not 100% certain.

  • 2
    You're correct. e'^2 is defined in the "The application of Ferrari's solution" and e^2 is defined earlier in the "From geodetic to ECEF coordinates" section.
    – mkennedy
    Commented Dec 19, 2017 at 19:55

a is one of the defining parameters; and b, e, and e' are some of the derived geometric constants of the WGS84 ellipsoid.

e is the first eccentricity. e' is the second eccentricity.

See page 3-2 and table 3.5 in NGA STND 0036_1 0 0_WGS84.pdf


A better way of doing it can be found at the end of this document: https://hal.archives-ouvertes.fr/hal-01704943v2/document

In this document, it's explained how to do it properly and including a C code so it's easy to copy and paste to see if the solution works.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.