[STATSGRASS] raster cross-stats

Agustin Lobo alobo at ija.csic.es
Thu Dec 13 08:09:23 EST 2001


On Thu, 13 Dec 2001, Roger Bivand wrote:

> Hi Agus!
> 
> Great to see you "here" too! 

Well, I actually wrote some (probably primitive) scripts
linking Splus and Grass ten years ago! I did pass the scripts
to Markus, and maybe they were at least useful to initially fuel the
current (and better) link with R.

> I'm enclosing below bits of correspondence
> between Markus, Helena and me of about two weeks ago, together with a
> draft shell script to use R functions for GRASS raster layers. My current
> feeling is that with R being easy to install and maintain, shell scripts
> using R (here for the leics dataset):

> > library(GRASS)
> > G <- gmeta()
> > work <- rast.get(G, c("landcov", "topo"), c(T,F))
> > res <- by(work$topo, work$landcov, summary)

etc.

Yes, I was aware of this option, which is very similar to 
my current solution: I import the necessary rasters to R
(using more general tools for raw binary images, as I 
use a number of different GIS and RS packages) and there
I compute the statistics.

But there are 2 problems with this approach:

1. We duplicate the information, which is really bad in the
case of images, as they can be huge (hyperspectral, multitemporal,
high resolution ...).

2. We import large objects to R, which is not precisely good and fast
at dealing with large objects.

In fact, an ideal link would let R work on the Grass files, but this
is probably asking for too much.

Therefore, a good solution would be performing this type of
"low level" stats directely at the GIS level, get a table
(of moderate size, my tables would have ~ 20000 rows) and
port it to R. If we have, for each category, mean, size, var,
median, mad ..., we can use R for further analysis. 

I do something similar with contingency tables: I use grass
r.stat to creat a 3 col table (categ.1_raster_1, categ.1_raster_2
nb_of_cells) and then a simple R function to compute
a contingency table. This is much faster and simpler than importing
the 2 rasters to R.

Opinions?


Agus






More information about the grass-stats mailing list