[GRASS-user] About Spatial PCA in GRASS

Shiva Khanal shiva_khanal at hotmail.com
Sun Jul 15 03:10:34 PDT 2018


Hi Vero,

Thank you for your response. The only issue I have running the EOF in R is the data size.

My raster stack is a MODIS time series.
> stk
class       : RasterStack
dimensions  : 2423, 2470, 5984810, 690  (nrow, ncol, ncell, nlayers)
resolution  : 499.9339, 499.9718  (x, y)
extent      : -85163.44, 1149673, 5656775, 6868207  (xmin, xmax, ymin, ymax)
coord. ref. : NA
names       : X2001.01.01, X2001.01.09, X2001.01.17, X2001.01.25, X2001.02.02, X2001.02.10, X2001.02.18, X2001.02.26, X2001.03.06, X2001.03.14, X2001.03.22, X2001.03.30, X2001.04.07, X2001.04.15, X2001.04.23, ...
min values  :           0,           0,           0,           0,           0,           0,           0,           0,           0,           0,           0,           0,           0,           0,           0, ...
max values  :         100,         100,         100,         100,         100,         100,         100,         100,         100,         100,         100,         100,         100,         100,         100, ...

The size of raster stack is ~8 mb.
>object.size(stk)
8699416 bytes

But, when I try to export it to a table, it becomes several GBs, which is too much for my desktop. (Though, my desktop has ~32 GB RAM with 8 cores)

Therefore, I am looking for the possibility of running i.pca but on transposed raster time series stack.

I am motivated by the nice grasswiki on PCA which compares the i.pca outputs against the R equivalent functions.
https://grasswiki.osgeo.org/wiki/Principal_Components_Analysis

I would appreciate any help on this.

Cheers,

Shiva


From: Veronica Andreo <veroandreo at gmail.com>
Sent: Friday, July 13, 2018 1:40 AM
To: shiva_khanal at hotmail.com
Cc: grass-user <grass-user at lists.osgeo.org>
Subject: Re: [GRASS-user] About Spatial PCA in GRASS

Hi Shiva,
El jue., 12 jul. 2018 a las 2:45, Shiva Khanal (<shiva_khanal at hotmail.com<mailto:shiva_khanal at hotmail.com>>) escribió:
Hi,

I am interested to run the spatial-mode PCA on raster time series. In R it is implemented as an ‘EOF’ function in spacetime Package. The function transposes the raster stack and applies ‘prcomp’ function.  I would like to know if there is any possible way to implement i.pca similar to this approach.

Interestingly, I found a very good tutorial on GRASS raster time series at https://grasswiki.osgeo.org/wiki/Temporal_data_processing/GRASS_R_raster_time_series_processing This includes the example using spacetime package to read GRASS raster time series into R.

there's also an alternative way to export raster time series from GRASS that was not there at the moment of creating the wiki: the add-on t.rast.out.xyz<http://t.rast.out.xyz> [0] that produces a table with xy coordinates and all dates in columns. You can then import that into R, transpose and run prcomp, EOF or others. Do you want it for gap-filling?

If you dare to implement EOF in GRASS, please go ahead!! I will be very happy to test and provide feedback, I've been wishing for such a thing (and also DINEOF) for a while :)

Maybe the devs can provide hints and advice on how to address it.

Best,
Vero

[0] https://grass.osgeo.org/grass74/manuals/addons/t.rast.out.xyz.html

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20180715/d62f38f5/attachment.html>


More information about the grass-user mailing list