Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 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?

like image 469
Matthew G. Avatar asked May 18 '15 15:05

Matthew G.


1 Answers

Latest pyproj version style

import pyproj

transformer = pyproj.Transformer.from_crs(
    {"proj":'geocent', "ellps":'WGS84', "datum":'WGS84'},
    {"proj":'latlong', "ellps":'WGS84', "datum":'WGS84'},
    )
x = 652954.1006
y = 4774619.7919
z = -2217647.7937
lon1, lat1, alt1 = transformer.transform(x,y,z,radians=False)
print (lat1, lon1, alt1 )

You got -24.887220848803032 82.2128095673836 -1069542.1692923503

like image 191
johnInHome Avatar answered Sep 19 '22 12:09

johnInHome