我正在尝试构建一些代码来查找连续位置和距离初始方位的最终方位。我使用的是destPoint,但是很难将它集成到某种递归函数中。(如果这是我需要的)
我尝试过递归函数,但似乎没有什么是接近的。
这基本上是我试图手动实现的,但我有更多的数据,并希望弄清楚如何做到这一点!
init<-c(149.6566667, -36.01983333)
bearing<-c(270, 315, 10, 20)
distance<-c(5,5,2,2)
a<-destPoint(init,bearing[1],distance[1])
a
b<-destPoint(a, bearing[2],distance[2])
b
c<-destPoint(b, bearing[3], distance[3])
c
d<-destPoint(c, bearing[4], distance[4])
d发布于 2019-04-09 13:51:42
可以使用来自purrr的accumulate2
library(geosphere)
library(purrr)
accumulate2(bearing, distance, destPoint, .init = init)[-1]
#[[1]]
# lon lat
#[1,] 149.6566 -36.01983
#[[2]]
# lon lat
#[1,] 149.6566 -36.0198
#[[3]]
# lon lat
#[1,] 149.6566 -36.01978
#[[4]]
# lon lat
#[1,] 149.6566 -36.01977https://stackoverflow.com/questions/55585778
复制相似问题