Recently I needed to create a series of temporally interpolated rasters in between two input raster maps, viz., a suitability distribution map under climate conditions in 2000 and under projected climate conditions in 2020. I though this would be a good time to try out the new temporal database in GRASS GIS and use the t.rast.gapfill function, which replaces gaps in a space time raster data-set with interpolated raster maps using linear interpolation.
I actually almost got there. It isn’t too hard to set up a temporal database. It does need some carefully reading through the manual pages to get an idea of the various options, but otherwise it is fairly straightforward process. But I will leave that for another post. This is a quick note about a function I hadn’t seen before, and which does what I need in one simple step; the r.series.interp function. It is actually mentioned in the help file of the t.rast.gapfill function, which uses it to do the interpolation.
Anyway, the function does exactly what I wanted to do: interpolating raster maps located (temporal or spatial) in between input raster maps at specific sampling positions (in this case, at different time steps). The difference with the t.rast.gapfill is that the user needs to give the time steps, thus allowing for much more flexibility in how those time steps are defined (I guess anything goes, as long as it falls in between the start and end time). The user needs to provide the following parameters:
input: the two layers with the start and end year
datapos: the start and end year
output: the names of the output layers
samplingpos: the sampling point positions, i.e., the years for which interpolated rasters should be created
To run the function below:
r.series.interp input=suit2000,suit2020 \ datapos=2000,2020 output=suit2005,suit2010,suit2015 \ samplingpos=2005,2010,2015
Nice and simple… one line instead of doing something with r.mapcalc in a loop. But also easier than first having to build a temporal database, define the temporal layers, etc.