Python pyproj convert ecef to lla

I want to convert x / y / z-ECEF positions to lla (lat / lon / alt) using WGS84 in python with pyproj, but it looks like the conversion fails.

Sample code 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 anyone see where the problem is?

EDIT: By now, I think the calculations are correct, only the data I receive from my receiver seems to be faulty. Can anyone confirm this?

+3


source to share


2 answers


I tested it with my own coordinate transformation program and I must say that the correct order is:

lon, lat, alt = pyproj.transform(ecef, lla, x, y, z, radians=True)

      

I think that when designing the library, they preferred to think of longitude as x-axis and latitude as y-axis, so they returned it in that order.

I prefer to use degree, so it's easier for me to read:

lon, lat, alt = pyproj.transform(ecef, lla, x, y, z, radians=False)
print lat, lon, alt

      

Here's the output:

-24.8872207779 82.2128095674 -1069542.17232

      



I changed the z value to get a more reasonable value, which is placed "next" to 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 changes, and the longitude is independent of the z value. This is because the z-axis points to the north pole.

If you want to know more about how this conversion is done take a look at this short description: https://en.wikipedia.org/wiki/Geographic_coordinate_conversion#From_geodetic_to_ECEF_coordinates

+2


source


lon, lat, alt = pyproj.transform(ecef, lla, x, y, z, radians=True)

      

Should be:



lat, lon, alt = pyproj.transform(ecef, lla, x, y, z, radians=True)

      

Since lla = pyproj.Proj(proj='latlong', ellps='WGS84', datum='WGS84')

specify latlong

order

0


source







All Articles