# NOT RUN {
require(raster)
data(tab)
data(eco3)
temp <- list()
# we create 4 simulated rasters for the data included in the object tab:
for(i in 1:4) {
temp[[i]] <- runif(19800, 0, 254)
temp[[i]] <- matrix(temp[[i]], 180, 110)
temp[[i]] <- raster(temp[[i]], crs="+proj=utm")
extent(temp[[i]])<-c(3770000, 3950000, 6810000, 6920000)
}
writeRaster(temp[[1]], "20040719b4.tif", overwrite = T)
writeRaster(temp[[2]], "20040719b3.tif", overwrite = T)
writeRaster(temp[[3]], "20091106b4.tif", overwrite = T)
writeRaster(temp[[4]], "20091106b3.tif", overwrite = T)
# Computing NDVI images:
eco.NDVI(tab, "COST", "NDVI", "LT5")
# Mean NDVI image computed over the NDVI images that we calculated:
eco.NDVI.post(tab, "COST", "NDVI", what = c("mean", "var"))
mean.ndvi <- raster("NDVI.COST.mean.tif")
plot(mean.ndvi)
# Extraction of the mean NDVI for each point in the object eco and plot
# of the data:
ndvi <- extract(mean.ndvi, eco3[["XY"]])
ndvi<- aue.rescale(ndvi)
plot(eco3[["XY"]][, 1], eco3[["XY"]][, 2], col=rgb(ndvi, 0, 0),
pch=15, main = "Mean NDVI", xlab = "X", ylab = "Y")
# }
# NOT RUN {
file.remove(c("NDVICOST20040719.tif", "NDVICOST20091106.tif",
"20040719b4.tif", "20040719b3.tif", "20091106b4.tif",
"20091106b3.tif", "NDVI.COST.mean.tif", "NDVI.COST.var.tif",
"NDVICOSTtime.tif"))
# }
Run the code above in your browser using DataLab