Does somebody knows if exist a package in R specifically for raster time series smoothing?

I´m using aproachs like this one (using the equation suggested by Hamunyella et al., 2013)

for (i in 2:(length(stacklist)-1)){
r <-  raster(stacklist[i])
r1 <- raster(stacklist[i-1])
r3 <- raster(stacklist[i+1])
r[((r-r1)<(-0.01*r1)) & ((r-r3)<(-0.01*r3))]<-r2[((r-r1)<(-0.01*r1)) & ((r-r3)<(-0.01*r3))]
writeRaster(r,filename=paste(substr(stacklist[i], p1+1, (p1+7)),"_cropmLname.tif",sep=""),format="GTiff",overwrite=TRUE)

It is fast, But there is not any easiest way? For example for implement another kind of filter, like Savitzky-Golay, Double-Logistic filtering?

1 Answer 1


Rather than looking for a specific package for raster time series you could look for functions for smoothing, and then use these with the calc function in the raster package. Here is an example for Savitzky-Golay:


  • I´m trying like this: fun2 <- function(x) { v=as.vector(x) z=na.spline(v) s1.ts2 = ts(v, start=c(2013,14), end=c(2016,19), frequency=44) x=sgolayfilt(s1.ts2) } s1<-calc(rasterstack, fun2) But when I call s1, the follow error appears: Error in .calcTest(x[1:5], fun, na.rm, forcefun, forceapply) : cannot use this function What dou think it is happening? Thank again!
    – Bindini
    Jun 24, 2016 at 19:00
  • 1
    Follow the (testing) steps in the link I provided. If that does not work, ask a new question Jun 24, 2016 at 21:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.