One way to do this is to divide your problem into two parts: 1. First, perform numerical interpolation based on the values ββof the raster, 2. and apply the interpolated values ββto the corresponding intermediate raster layers.
Idea . Create a data frame of raster layer values ββ(), the time index that is used for the data frame, and then apply linear interpolation to these numbers. For linear interpolation, I use approxTime from the simecol package.
For your example above,
library(raster) library(simecol) df <- data.frame("2006" = 1:9, "2008" = 3:11, "2010" = 5:13, "2012"=7:15)
This gives:
# times X1 X2 X3 X4 X5 X6 X7 X8 X9 #1 2006 1 2 3 4 5 6 7 8 9 #2 2007 2 3 4 5 6 7 8 9 10 #3 2008 3 4 5 6 7 8 9 10 11 #4 2009 4 5 6 7 8 9 10 11 12 #5 2010 5 6 7 8 9 10 11 12 13 #6 2011 6 7 8 9 10 11 12 13 14 #7 2012 7 8 9 10 11 12 13 14 15
Then you can save this and take each row and apply to the values ββof this raster object this year.
Note: approxTime does not perform linear extrapolation. It just takes the closest value, so you need to consider this.
source share