ECEF到lla(lat,lon,alt)在python中

时间:2017-01-31 20:31:09

标签: python gps coordinates latitude-longitude coordinate-transformation

在Python中寻找ECEF到lla的实现。我见过pyproj,但在我的项目中已有ECEF_to_LLA转换,我的任务只是将其扩展为3D维度。最后转换了JAVA代码,这是在ECEF to lla (lat,lon,alt) in java发布的。

def spherical_ecef_to_lla3D(ecefArr):
# convert ECEF coordinates to LLA
# test data : test_coord = [2297292.91, 1016894.94, -5843939.62]
# expected result : -66.8765400174 23.876539914 999.998386689   

    x = ecefArr[0]
    y = ecefArr[1]
    z = ecefArr[2]

    a = 6378137;
    e = 8.1819190842622e-2;

    asq = math.pow(a,2);
    esq = math.pow(e,2);

    b   = math.sqrt(asq * (1 - esq) );
    bsq = math.pow(b, 2);

    ep  = math.sqrt((asq - bsq)/bsq);
    p   = math.sqrt(math.pow(x, 2) + math.pow(y, 2) );
    th  = math.atan2(a * z, b * p);

    lon = math.atan2(y, x);
    lat = math.atan2( (z + math.pow(ep, 2) * b * math.pow(math.sin(th), 3)), (p - esq * a * math.pow(math.cos(th), 3)) );
    N = a / ( math.sqrt(1 - esq * math.pow(math.sin(lat), 2)) );
    alt = p / math.cos(lat) - N; 

    lon = lon * 180 / math.pi;
    lat = lat * 180 / math.pi;
    print lat, lon, alt

    return BeanSphere(lat, lon, alt);

0 个答案:

没有答案