使用R计算两点(纬度,经度)之间的地理空间距离的函数 [英] Function to calculate geospatial distance between two points (lat,long) using R

查看:636
本文介绍了使用R计算两点(纬度,经度)之间的地理空间距离的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对经纬度较长的点进行了地理编码,我想使用R计算它们之间的距离.这似乎很简单,但是我找不到能轻松实现的功能.我一直在尝试使用gdistance软件包来实现它,但是它看起来非常复杂并且面向图形化,我只需要一个数字.类似于distanceBetween(pointA,pointB)这样的东西,它返回一个数字.

I have geocoded points in long, lat format, and I want to calculate the distance between them using R. This seems pretty straight forward, yet I can't find a function that will do it easily. I've been attempting to do it with the gdistance package, but it seems very convoluted and oriented to graphing, I just need a number. Something like distanceBetween(pointA,pointB) that returns a number.

推荐答案

加载geosphere包时,您可以使用许多不同的功能

Loading the geosphere package you can use a number of different functions

library(geosphere)
distm(c(lon1, lat1), c(lon2, lat2), fun = distHaversine)

也:

distHaversine()
distMeeus()
distRhumb()
distVincentyEllipsoid()
distVincentySphere()

...

这篇关于使用R计算两点(纬度,经度)之间的地理空间距离的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆