测量 lat/lon 坐标和 utm 坐标之间的距离

Measure distance between lat/lon coordinates and utm coordinates

我有一组 lat/lon 坐标用于不同的节点。
由于我必须在模拟器中表示这些位置,因此我必须将它们转换为笛卡尔坐标。
为此,我使用 python 包 pyproj。

lat1 = 50.0
lon1 = 10.0
lat2 = 50.5
lon2 = 10.5

x1, y1, z1 = wgs84_to_utm32(lat1, lon1, 0.0)
x2, y2, z2 = wgs84_to_utm32(lat2, lon2, 0.0)

print(distance_haversine(lat1, lon1, lat2, lon2))
print(distance_cartesian(x1, y1, x2, y2))

输出是:

66012.5130481
102485.874713

相差超过 36 公里。

所以我的问题是,如何转换 lat/lon 坐标以保留距离。我不关心最小的错误。

编辑:

#
# Convert WGS84 (Geographic) coordinates to UTM32 (Germany)
#
def wgs84_to_utm(lat, lon, alt):
   wgs84 = Proj(init='epsg:4326')
   utm_de = Proj(init='epsg:32632')  # utm germany = 32

   return transform(wgs84, utm_de, lat, lon, alt)

编辑 2:
好吧,我知道我正在尝试比较球体上的距离与平面上的距离。

但由于我正在模拟 WLAN 节点,因此这些节点之间的距离至关重要。但除了他们的 lat/lon 坐标,我没有其他信息。

我将如何在平面上表示那些 lat/lon 坐标,以便保留距离?

编辑 3:

def distance_haversine(lat1, lon1, lat2, lon2):
    # approximate radius of earth in km
    R = 6373.0 * 1000

    lat1 = radians(lat1)
    lon1 = radians(lon1)
    lat2 = radians(lat2)
    lon2 = radians(lon2)

    dlon = lon2 - lon1
    dlat = lat2 - lat1

    a = sin(dlat / 2) ** 2 + cos(lat1) * cos(lat2) * sin(dlon / 2) ** 2
    c = 2 * atan2(sqrt(a), sqrt(1 - a))

    distance = R * c

    return distance


def distance_cartesian(x1, y1, x2, y2):
    dx = x1 - x2
    dy = y1 - y2

    return sqrt(dx * dx + dy * dy)

在转换为 utm 时某处出错。尝试使用 utm 模块

import utm

lat1 = 50.0
lon1 = 10.0
lat2 = 50.5
lon2 = 10.5

x1, y1, z1, u = utm.from_latlon(lat1, lon1)
x2, y2, z2, u = utm.from_latlon(lat2, lon2)

print(distance_haversine(lat1, lon1, lat2, lon2))
print(distance_cartesian(x1, y1, x2, y2))

输出:

66012.51304805529
66047.84250743943