大地坐标系和空间直角坐标系的转换
生活随笔
收集整理的這篇文章主要介紹了
大地坐标系和空间直角坐标系的转换
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
大地坐標系轉空間直角坐標系
import math
A_ALIS = 6378137
B_ALIS = 6356752.3142
E = math.sqrt(A_ALIS * A_ALIS - B_ALIS * B_ALIS) / A_ALIS
def transform_latlonhei2xyz(lon, lat, h):
""" 大地坐標系 轉 空間直角坐標系 """
lon, lat, h = math.radians(float(lon)), math.radians(float(lat)), float(h)
W = math.sqrt(1 - E * E * math.sin(lat) * math.sin(lat))
N = A_ALIS / W
x = (N + h) * math.cos(lat) * math.cos(lon)
y = (N + h) * math.cos(lat) * math.sin(lon)
z = (N * (1 - E * E) + h) * math.sin(lat)
return x, y, z
print(transform_latlonhei2xyz(lon=121.4533008922, lat=31.1720088176, h=15.069))
# (-2850172.518796192, 4659579.331978275, 3282233.397176004)
空間直角坐標系轉大地坐標系
import math
A_ALIS = 6378137
B_ALIS = 6356752.3142
E2 = (A_ALIS * A_ALIS - B_ALIS * B_ALIS) / (B_ALIS * B_ALIS)
def transform_xyz2lonlathei(x, y, z):
lon = math.degrees(math.atan2(y, x))
S = math.atan2(z * A_ALIS, math.sqrt(x * x + y * y) * B_ALIS)
lat = math.atan2(z + E2 * B_ALIS * math.pow(math.sin(S), 3),
(math.sqrt(x * x + y * y) - E * E * A_ALIS * math.pow(math.cos(S), 3)))
W = math.sqrt(1 - E * E * math.sin(lat) * math.sin(lat))
N = A_ALIS / W
hei = math.sqrt(x * x + y * y) / math.cos(lat) - N
lat = math.degrees(lat)
return lon, lat, hei
print(transform_xyz2lonlathei(x=-2850172.518796192, y=4659579.331978275, z=3282233.397176004))
#(121.4533008922, 31.1720088176, 15.06900000013411)
總結
以上是生活随笔為你收集整理的大地坐标系和空间直角坐标系的转换的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 需求朔源——MD_PEGGING_NOD
- 下一篇: 华为支付事业群总裁马传勇:鸿蒙3.0将于