Last active
February 6, 2019 01:26
-
-
Save uhho/63750c4b54c7f90f37f958cc8af0c718 to your computer and use it in GitHub Desktop.
LatLonAlt to ECEF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# WGS84 ellipsoid constants | |
WGS84_A = 6378137 # radius | |
WGS84_E = 8.1819190842622e-2 # eccentricity | |
def LLA2ECEF(lat, lon, alt): | |
""" | |
Converts latitude (deg), longitude (deg) and altitude (m) to ECEF frame | |
https://en.wikipedia.org/wiki/Geographic_coordinate_conversion#From_geodetic_to_ECEF_coordinates | |
Returns: | |
X, Y, Z in meters | |
""" | |
clat = np.cos(np.deg2rad(lat)) | |
slat = np.sin(np.deg2rad(lat)) | |
clon = np.cos(np.deg2rad(lon)) | |
slon = np.sin(np.deg2rad(lon)) | |
N = WGS84_A / np.sqrt(1.0 - (WGS84_E**2) * (slat**2)) | |
X = (N + alt) * clat * clon | |
Y = (N + alt) * clat * slon | |
Z = (N * (1.0 - WGS84_E * WGS84_E) + alt) * slat | |
return X, Y, Z |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment