我想使用经度和纬度计算Excel文件中某些位置之间的距离,使用R软件,我以前从未尝试过这样做。如果有人可以帮助我,那将是非常好的。
非常感谢提前。
答案 0 :(得分:0)
Try this to get distance in meters:
acos(sin(lat1)*sin(lat2) + cos(lat1)*cos(lat2)*cos(lon2-lon1)) * 6371000
Example : Distance between London (lat=52, lng=0) and Mumbai (lat=19, lng=72) is approx 8000 Kms
> acos( sin(19)*sin(52) + cos(19)*cos(52)*cos(72-0) ) * 6371000
[1] 8041318
Seems to be correct.
Reference: http://www.movable-type.co.uk/scripts/latlong.html