# NOT RUN {
set.seed(0)
# load example ndvi and dem data of Navarre
data(ex.ndvi.navarre)
data(ex.dem.navarre)
# plot example data
genPlotGIS(ex.ndvi.navarre)
genPlotGIS(ex.dem.navarre)
# distorts 5% of the original ndvi data by
# altering 50% its values
for(x in c(2,5)){
aux <- sampleRandom(ex.ndvi.navarre[[x]],
ncell(ex.ndvi.navarre) * 0.05,
cells = TRUE,
na.rm = TRUE)
ex.ndvi.navarre[[x]][aux[,1]] <- aux[,2] * 1.5
}
genPlotGIS(ex.ndvi.navarre)
# smoothing the image using the DEM as covariate
smth.ndvi <- genSmoothingCovIMA(rStack = ex.ndvi.navarre,
cStack = ex.dem.navarre,
Img2Process = c(2))
# plot the distorted 1, smoothed 1,
# distorted 5, smoothed 5 images
plot(stack(ex.ndvi.navarre[[2]],
smth.ndvi[[1]],
ex.ndvi.navarre[[5]],
smth.ndvi[[2]]))
# }
Run the code above in your browser using DataLab