I have a number of GPS points.
points <- structure(list(counter = 1:6, lon = c(11.8300715, 11.8296697,
11.8268708, 11.8267236, 11.8249612, 11.8251062), lat = c(48.1099048,
48.10884, 48.1067431, 48.1066077, 48.1037673, 48.103318), dist = c(46.8463805878941,
33.4921440879536, 10.6101735030534, 18.6085009578724, 6.97253109610173,
9.8912817449265)), row.names = c(NA, -6L), class = c("data.table",
"data.frame"))
I would like to smooth the track out. To do so i would like to apply the following calculation
points[n].latitude = points[n-1].latitude * 0.3 + points[n].latitude * .4 + points[n+1].latitude * .3
points[n].longitude = points[n-1].longitude * 0.3 + points[n].longitude * .4 + points[n+1].longitude * .3
So basically i need to iterate through the structure and apply the operation to previos and the next entry. What is the best way to do so? I would like to avoid a for loop. Thank you for advice.