r语言 - 如何按日期计算坐标数据之间的距离



我的数据形式为:

* date        lat      long
* 01/01/13    47        118
* 01/01/13    48        119
* 01/01/13    47        118
* 02/01/13    46        119
* 02/01/13    46        119
* 02/01/13    48        118

我希望能够按日期计算点之间的距离,例如 01/01/13,从第一行到第二行,然后从第二行到第三行的距离等。我的实际数据每个日期超过 3 点。

函数

earth.dist(lats, dist = TRUE) 

这样做,但也会计算日期之间的距离。有什么想法吗?谢谢。

library(data.table)
DT <- as.data.table(YourDataFrame)
DT[, earth.dist(c(lat, long)), by=date]

最新更新