wgs84坐标系转换为ECEF坐标系
#wgs84坐标系转换为ECEF坐标系
import math
def WGS84toECEF(latitude,longitude,height):
a = 6378137
b = 6356752.314245
e = (a * a - b * b) / (a * a)
coslat = math.cos(latitude * math.pi/180)
sinlat = math.sin(latitude * math.pi/180)
coslon = math.cos(longitude * math.pi/180)
sinlon = math.sin(longitude * math.pi/180)
n = a/(math.sqrt(1 - e * sinlat * sinlat))
nh = n + height
x = nh * coslat * coslon
y = nh * coslat * sinlon
z = (b * b * n / (a * a) + height) * sinlat
return x,y,z
print(WGS84toECEF(116.413634,39.910843,0))
ECEF坐标系转换为wgs84坐标系
#ECEF坐标系转换为wgs84坐标系
import pyproj
def ecef2lla(x,y,z):
#ecef转换为经纬高
ecef = pyproj.Proj(proj='geocent',ellps='WGS84', datum='WGS84')
lla = pyproj.Proj(proj='latlong',ellps='WGS84', datum='WGS84')
lon, lat, alt = pyproj.transform(ecef,lla,x,y,z,radians=False) #用弧度返回值
return lat,lon,alt



