[R-sig-Geo] Problem with operations on large files ("cannot allocate vector of size xx")

Benjamin Leutner benjamin.leutner at uni-wuerzburg.de
Wed Feb 1 14:01:25 CET 2017


You can have a look at the code of rasterPCA in my RStoolbox package, it 
does exactly that.
Either you fit the PCA only on a subset of pixels and apply it to all, 
or you calculate the covariance or correlation matrix first in a 
stepwise fashion and then build the PCA from it.

Cheers,
Benjamin

On 01.02.2017 13:19, Kamil Konowalik wrote:
> Hi All,
> I have a problem with operations on large datasets. I have a several raster files (43) and I would like to make a PCA on them.
> I'm using those simple commands:
>
> files <- list.files("G:/GIS/raster_TIFF",pattern='tif',full.names=TRUE)
> s <- raster::stack(files)
> pca<-princomp(na.omit(values(s)), cor=TRUE)
>
> But after the last one I'm getting an error: "cannot allocate vector of size 6.6 Gb".
> I searched the internet and there are some advices but I couldn't found anything helpful. I'm using Windows 7 64 bit with 8 GB of RAM so it is not an issue with 32 bit. Also I would prefer to find a solution which can use my current resources rather than buying additional RAM. I thought that maybe "bigmemory" package will be a solution but I couldn't make it work. I tried also different file types (ASCII, RASTER, GTiff) but that doesn't help neither.
> It should be a simple and a common problem but I can't figure answer on my own so if you have any working solution I would appreciate it.
> Thanks in advance!
> Best regards,
> Kamil
>
> _______________________________________________
> 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