I have several large rasters that I want to process in a PCA (to produce summary rasters). I have seen several examples whereby people seem to be simply calling prcomp or pr
here is a working solution:
library(raster) filename <- system.file("external/rlogo.grd", package="raster") r1 <- stack(filename) pca<-princomp(r1[], cor=T) res<-predict(pca,r1[])
Display result:
r2 <- raster(filename) r2[]<-res[,1] plot(r2)