首页 > 解决方案 > 如何使用标准 WGS84 将纬度和经度转换为具有坐标中心的 X 和 Y?

问题描述

例如,我有一个坐标列表(纬度,经度):

Coords_of_points = [(57.769999999999996, 108.06), 
                    (60.271336095306005, 119.70058684113518), 
                    (55.44781555321857, 121.56598882454766), 
                    (42.39597453807919, 141.90642068006264), 
                    (47.416832694979675, 126.65598006176236)]
Center_of_coordinates = (48.528055555555554, 135.18805555555556)

为了从 计算点的 X 和 Y Center_of_coordinates,我使用这个函数:

def transform(Coords_of_points, Center_of_coordinates):
    for i in range(len(Coords_of_points)):
        line = Coords_of_points[i]
        rad = 6372795
        lat_point = math.radians(line[0])
        lon_point = math.radians(line[1])
        lat_0 = math.radians(Center_of_coordinates[0])
        lon_0 = math.radians(Center_of_coordinates[1])
        cl1 = math.cos(lat_0)
        cl2 = math.cos(lat_point)
        sl1 = math.sin(lat_0)
        sl2 = math.sin(lat_point)
        delta = lon_point - lon_0
        cdelta = math.cos(delta)
        sdelta = math.sin(delta)
        y = math.sqrt(math.pow(cl2 * sdelta, 2) + math.pow(cl1 * sl2 - sl1 * cl2 * cdelta, 2))
        x = sl1 * sl2 + cl1 * cl2 * cdelta
        ad = math.atan2(y, x)
        dist = ad * rad
        x = (cl1 * sl2) - (sl1 * cl2 * cdelta)
        y = sdelta * cl2
        z = math.degrees(math.atan(-y / x))
        if (x < 0):
            z = z + 180
        z2 = (z + 180.) % 360. - 180
        z2 = - math.radians(z2)
        anglerad2 = z2 - ((2 * math.pi) * math.floor((z2 / (2 * math.pi))))
        x = round(((math.sin(anglerad2) * dist) / 1000), 3)
        y = round(((math.cos(anglerad2) * dist) / 1000), 3)
        yield x,y

当点位于 附近时,此功能效果很好Center_of_coordinates,但如果它们位于远离Center_of_coordinates,X 和 Y 计算错误,我猜这是由于地球曲率而发生的。

所以,如果我有 Point (57.769999999999996, 108.06),它的 X 和 Y fromCenter_of_coordinates将被计算为(-1577, 1326.651)。正确答案应该是:(-1590, 1338.34)

有人知道如何修改或更改整个算法以使用 WGS84 获得正确的 X 和 Y 点吗?

标签: pythonmathcoordinatesconverterswgs84

解决方案


推荐阅读