1

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])
r2<-mean(r1,r3)
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?

4

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:

https://stackoverflow.com/questions/37843942/smoothen-rasterstack-using-the-savitzky-golay-sgolayfilt-signal-in-r/37846229#37846229

  • 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 '16 at 19:00
  • 1
    Follow the (testing) steps in the link I provided. If that does not work, ask a new question – Robert Hijmans Jun 24 '16 at 21:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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