ecef2geodetic
ahrs.common.frames.ecef2geodetic(x: float, y: float, z: float, a: float = 6378137.0, b: float = 6356752.3142) → ndarray : Transform cartesian coordinates in ECEF-frame to Geodetic Coordinates [ZHP11].
code
Given the Cartesian coordinates
in the Earth-Centered Earth-Fixed (ECEF) frame, we can start by computing
the geodetic longitude :
Then, we iteratively compute the geodetic latitude using the
initial estimation:
with .
Now we iterate until the difference between two consecutive latitudes
( and ) is smaller than a given threshold
. Each iteration updates the values as follows:
where is the radius of curvature in the vertical prime, and
is the square of the first eccentricity of the ellipsoid.
The value of is empirically found to perform well when set
to in this implementation.
The altitude (height) is computed as:
Note
The altitude has an accuracy up to 0.1 m (10 cm), which is
enough for most applications.
The latitude and longitude are returned in degrees. The altitude is
returned in meters.
Parameters:
: - **x** (*float*) – ECEF x-coordinate, in meters.
- **y** (*float*) – ECEF y-coordinate, in meters.
- **z** (*float*) – ECEF z-coordinate, in meters.
- **a** (*float, default: 6378137.0*) – Ellipsoid’s equatorial radius, in meters. Defaults to Earth’s.
- **b** (*float, default: 6356752.3142*) – Ellipsoid’s polar radius, in meters. Defaults to Earth’s.
Returns:
: **lla** – Geodetic coordinates [latitude, longitude, altitude].
Return type:
: numpy.ndarray
Examples
```defaultfrom ahrs.common.frames import ecef2geodetic x = 4_201_000 y = 172_460 z = 4_780_100 ecef2geodetic(x, y, z) array([48.85616162, 2.35079383, 67.37006803]) ```