I want to convert x/y/z-ECEF positions to lla (lat/lon/alt) using WGS84 in python with pyproj but it seems like the conversion fails.
Example code is here:
import pyproj
# Example position data, should be somewhere in Germany
x = 652954.1006
y = 4774619.7919
z = -2217647.7937
ecef = pyproj.Proj(proj='geocent', ellps='WGS84', datum='WGS84')
lla = pyproj.Proj(proj='latlong', ellps='WGS84', datum='WGS84')
lon, lat, alt = pyproj.transform(ecef, lla, x, y, z, radians=True)
print lat, lon, alt
Can someone see where the problem is?
EDIT: By now I guess the calculations are correct, just the data I get from my receiver seems to be faulty. Can someone confirm that?
I tested it with my own self-made coordinate transformation program and have to say the correct order is:
lon, lat, alt = pyproj.transform(ecef, lla, x, y, z, radians=True)
I think when the designed the library they prefered to think about the longitude as the x-axis and latitude as the y-axis, so they returned it in that order.
I prefer to use degree, so it is easier for me to read it:
lon, lat, alt = pyproj.transform(ecef, lla, x, y, z, radians=False)
print lat, lon, alt
There the ouput is:
-24.8872207779 82.2128095674 -1069542.17232
I changed the z value to get a more reasonable value which is placed 'near' the surface:
x= 652954.1006
y = 4774619.7919
z =-4167647.7937
Then I get:
-41.0445318235 82.2128095674 2274.39966936
You can also see that only the latitude value is changing and the longitude is independent of the z-value. This is due to the fact that the z-axis is pointing to the north-pole.
If you want to read more about how this transformation is done look at this short description: https://en.wikipedia.org/wiki/Geographic_coordinate_conversion#From_geodetic_to_ECEF_coordinates