[R-sig-Geo] pca on raster layers with NA's
César Capinha
nrevistada at yahoo.co.uk
Tue Jul 23 19:42:42 CEST 2013
Dear all,
I have a set of 7 overlaying rasters for which I want to perform a principal components analysis and subsequently extract the corresponding maps of the two or three principal components (i.e. the scores).
I've been trying to do this for a while, but I keep getting stuck in the beginning with this error message: "Error in cov.wt(z) : 'x' must contain finite values only"
I think this is related to the presence of NA's in the raster layers but I'm not being able to figure out a way to solve this issue .
Any suggestions ?
#code begin
library(raster)
elev <- raster("elev.asc")
expo <- raster("expo.asc")
wind <- raster("wind.asc")
pop <- raster("pop.asc")
prec <- raster("prec.asc")
temp <- raster("temp.asc")
access <- raster("access.asc")
s <- c("elev", "expo", "wind", "pop", "prec", "temp", "access")
pca<-princomp(s, cor=T)
#code end
Many thanks in advance.
Edward Correia
More information about the R-sig-Geo
mailing list