# \donttest{
library(doParallel)
library(raster)
library(rasterVis)
library(RColorBrewer)
dfB = landsat106[landsat106$year >= 2000,]
matB = as.matrix(dfB[,-c(1:2)])
year = dfB$year
doy = dfB$doy
if(require(doParallel))
registerDoParallel(1)
res <- stfit_landsat(year, doy, matB, 31, 31, nnr=30,
use.intermediate.result = FALSE, intermediate.save = FALSE, var.est = TRUE)
## visualize the imputed results
idx = c(res$idx$idx.allmissing[150], res$idx$idx.partialmissing[c(30, 60, 90)])
rst_list = list()
for(i in 1:length(idx)){
rst_list[(i-1)*3+1] = raster(matrix(matB[idx[i],], 31))
rst_list[(i-1)*3+2] = raster(matrix(res$imat[idx[i],], 31))
rst_list[(i-1)*3+3] = raster(matrix(res$sdmat[idx[i],], 31))
}
s = stack(rst_list)
levelplot(s, index.cond=list(c(seq(1, 12, 3), seq(2, 12, 3), seq(3, 12, 3))),
par.setting = rasterTheme(panel.background=list(col="black"),
region = brewer.pal(9, 'YlOrRd')),
names.attr = c(rbind(paste0("Original ", idx),
paste0("Imputed ", idx),
paste0("Std. Error ", idx))),
layout = c(4,3))
# }
Run the code above in your browser using DataLab