Python pyproj convert ecef to lla

后端 未结 3 1833
夕颜
夕颜 2021-02-04 12:51

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:



        
3条回答
  •  死守一世寂寞
    2021-02-04 13:29

    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

提交回复
热议问题