为什么 cartopy 和 basemap 的反函数计算距离的结果不同?

Why do the inverse function from both cartopy and basemap have different results to calculate distance?

我想计算地球表面两点之间的距离(以米为单位)

我已经尝试使用底图和 cartopy,但两者的结果不同。

底图:

import mpl_toolkits.basemap.pyproj as pyproj

k = pyproj.Geod(ellps="WGS84")
distance = k.inv(c0[1], c0[0], c1[1], c1[0])[-1]/1000.

卡托比:

import cartopy.geodesic as gd

k = gd.Geodesic() // defaults to WGS84
distance = k.inverse(c0, c1).base[0,0]/1000

其中 coord0 和 coord1 都是大小为 2 的 numpy 数组,具有坐标的经纬度。

c0 = numpy.array([77.343750, 22.593726])
c1 = numpy.array([86.945801, 23.684774])

Cartopy 输出:990.6094719605074

底图输出:1072.3456344712​​142

对于底图,您必须使用正确的(经、纬度)顺序:

distance = k.inv(c0[0], c0[1], c1[0], c1[1])[-1]/1000.

和Cartopy的结果一致,这是正确的结果:

990.6094719605074