[R-sig-Geo] create rasters using pca components of bioclimatic variables

Robert J. Hijmans r.hijmans at gmail.com
Thu Nov 21 18:40:17 CET 2013


Andre,

The below is slightly modified from the example in
?raster::predict

library(raster)
logo <- brick(system.file("external/rlogo.grd", package="raster"))
sr <- sampleRegular(logo, min(100000, ncell(logo)))
pca <- prcomp(sr)
x <- predict(logo, pca, index=1:3)
plot(x)


Robert

On Thu, Nov 21, 2013 at 7:25 AM, Andre <pintodasilva.a at gmail.com> wrote:
> Hi,
>
> I performed pca in 4 bioclimatic variables using princomp.
>
> ##stack rasters
> myExpl <- raster::stack (Bio01,Bio02,Bio03,Bio04)
> ##read as data.frame
> m <- as.data.frame(myExpl)
> ##pca (here I used formula to activate na.action)
> pca <- princomp(formula = ~., data = m, cor = TRUE, na.action=na.exclude)
>
> Now I would like to create rasters (with the same size as BIO01) for each
> component of the PCA to use them as input in biomod2.
>
> What is the best way to do this?
>
> Many thanks,
>
> Andre
>
>
>
> --
> View this message in context: http://r-sig-geo.2731867.n2.nabble.com/create-rasters-using-pca-components-of-bioclimatic-variables-tp7585158.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list