Hey Edward,
you may find this function useful.

https://github.com/environmentalinformatics-marburg/magic/blob/master/eot/src/EotDenoise.R

It is designed to 'denoise' raster data (i.e. calculate all possible 
PCAs and only keep the first k - an integer you specify - PCAs for 
reconstruction).
Your data needs to be a raster stack, so in your code, instead of c'ing 
your rasters, create a stack using stack(elev, expo, ...)

We have, so far, not explicitly tried the code on data with missing 
values, so I cannot promise that it works, but I guess it is worth a try.

Let me know how it pans out.

Cheers
Tim


On 07/23/2013 07:42 PM, César Capinha wrote:
> 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
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

-- 
#####################################
Tim Appelhans
Department of Geography
Environmental Informatics
Philipps Universität Marburg
Deutschhausstraße 12
35032 Marburg (Paketpost: 35037 Marburg)
Germany

Tel +49 (0) 6421 28-25957

http://environmentalinformatics-marburg.de/


        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to