When performing satellite positioning calculations such as GPS, it is possible to represent the position on the earth.
--XYZ Cartesian coordinate system defined by ECEF (earth-centered earth-fixed) --Geodetic datum, a method of expressing latitude, longitude, and height
Two are used. The height calculated in the vertical direction from the sphere when the earth is modeled as an ellipsoid is called the "ellipsoid height", and the height from the geoid (corresponding to the average sea level) is called the altitude.
There are many reference materials,
-WGS84 and Coordinate Conversion Story --WikiPedia's Latitude
And so on.
My uncle used to use the library he implemented himself, but when I saw it today, I found a python library, so I'll make a note of it.
pymap3d
--Source available at https://github.com/geospace-code/pymap3d --Registered at https://pypi.org/project/pymap3d/. I was able to install it with pip without any problems.
The desired coordinate transformation function can be found in pymap3d.ecef.ecef2gedetic
. As the name suggests.
The coordinate value of Tsukuba 1 of the electronic reference point is used.
from math import isclose
from pytest import approx
from pymap3d.ecef import ecef2geodetic
def test_ecef2geodetic():
x_ecef = [-3957162.4119, 3310203.4927, 3737752.2980]
x_geod = [36.106112803, 140.08720184, 70.336]
x_geod_from_ecef = ecef2geodetic(x_ecef[0], x_ecef[1], x_ecef[2])
print( "x_geod_from_ecef=", x_geod_from_ecef)
print( "x_geod=", x_geod)
assert x_geod[0] == approx( x_geod_from_ecef[0] )
assert x_geod[1] == approx( x_geod_from_ecef[1] )
assert isclose(x_geod[2], x_geod_from_ecef[2], rel_tol=0.01)
When I do pytest --capture = no -v
, a warning appears for some reason, but it was OK.
x_geod_from_ecef= (36.10611280179599, 140.08720184317684, 70.33612007893962)
x_geod= [36.106112803, 140.08720184, 70.336]
PASSED
I will recommend this from now on.
Recommended Posts