首页 > 解决方案 > 使用 Python haver 和 R distHaversine 计算距离时的结果差异

问题描述

使用 Python 和 R 计算两个位置之间的距离时,我得到不同的结果。Python似乎是准确的

Python

import haversine as hs
hs.haversine((41.8777, -87.6353), (41.8915, -87.6268))        # 1.688136 km
hs.haversine((28.426846, 77.088834), (28.394231, 77.050308))  # 5.229712 km  

R

library(geosphere)
distHaversine(c(41.8777, -87.6353), c(41.8915, -87.6268))     # 948.3439 meters
distHaversine(c(28.426846,77.088834), c(28.394231,77.050308)) # 4364.968 meters

为什么R中的计算不同?

标签: pythonrhaversinegeosphere

解决方案


推荐阅读