[GRASS-stats] GRASS within R interface issues

Roger Bivand Roger.Bivand at nhh.no
Sat May 5 06:41:42 EDT 2012


On Fri, 4 May 2012, Laura S wrote:

> Dear Roger:
>
> Thank you for your response. I will see if I can code in something to 
> make it work. The executable does not work the way you described on my 
> computer, so maybe I installed something wrong. If all can be run in R 
> gui then I am fine with that, but I keep reading that it is better to 
> run R in GRASS directly. The files I will be importing are large, so it 
> would be more useful to use GRASS than the limited memory of R.

Using R in GRASS directly has two meanings, but not the third you imply. 
The first is that R is run "on top of" GRASS, transferring GRASS data to R 
to run statistical functions on the imported data as R objects in memory, 
and possibly tranfer the results back to GRASS.

The second is to leave the data mostly in GRASS, and to use R as a 
scripting language "on top of" GRASS with execGRASS() - in this case, 
little data is moved to R, so memory constraints are not important, but R 
functionality is not available.

The third meaning that you imply is to be able to use R functions on GRASS 
data without moving the data to the R workspace. This is not possible as 
such. Two possibilities exist, one to tile the GRASS region with g.region 
in a loop, and only transfer single tiles to R for processing. This would 
be similar to using the R raster package on GRASS raster data exported 
using r.out.gdal, which also permits looping over tiles of data. It is 
possible to do the same using r.out.gdal exported GRASS data with the 
offset= and region.dim= arguments to readGDAL(). None of these is 
available without scripting yourself.

>
> I am sorry for any frustration. I can use computers, and I can program, 
> but there may be some gaps as I have taught myself from scratch.

Learning oneself is fine, but one also needs to look carefully at example 
code to see whether the meanings one is giving to concepts are the only 
ones possible (ontology?) - here your understanding of "direct" has not 
the appropriate one. Explaining what you really wanted to do to start with 
would have saved a lot of time.

>
> For now, I will see if I can use QGIS with R instead as it is more user 
> friendly. Then, I can progress to GRASS/R. I was able to run QGIS with 
> GRASS. I know there is a R/QGIS plugin.
>

This wins you nothing at all on memory, I'm afraid. QGIS will just be a 
side-track, because for R functions you still need all the data in memory.

The apparent memory limitations of R are also less significant than many 
feel, especially if you script to avoid copying, use a 64-bit system, and 
design your workflow carefully. If by big data you mean hundreds of bands 
of scenes each with billions of pixels, I would ask what kinds of 
inferences you want to do, that would justify doing statistics on "too 
much" data. Is sampling an option to get to the results you need? Using 
"too big" data prevents you using advanced statistical methods, which may 
actually give more insight into the underlying scientific problems.

Roger

>
> Cheers,
> Laura
>

-- 
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the grass-stats mailing list