[STATSGRASS] Problems using rast.get() in a script

William Hudspeth bhudspeth at edac.unm.edu
Mon Sep 12 16:40:41 EDT 2005


Hello, 

I am using R 2.0.1, GRASS 5.3, and the GRASS R module 0.2-2 on a Linux
machine running Fedora Core 3. 

I am using the R GRASS module in a Python script to return basic
statistics about the values in GRASS raster layers. A simple sequence of
events in my code looks like this:

1. Edit/change the region settings for a specific GRASS location using a
Python-based system command.
2. Create a temporary raster in GRASS with r.mapcalc.
3. Run gmeta() to load the location metadata/region settings into a
list.
4. Run rast.get() to move the temporary GRASS raster into an R data
structure.
5. Perform basic statistics on the R representation of the raster.
6. Remove the temporary GRASS raster with g.remove.
7. Repeat the above steps.

I can run this script once with no problems. The second time, however,
it crashes at the rast.get() function, with an error message stating
that the "Current GRASS region changed: north". While the technical
notes on the internet stress that "rast.get() assumes that the region of
the GRASS LOCATION has not been changed since gmeta() was last run," I
must stress that gmeta() is run immediately before rast.get() in my
code. I would appreciate any insight on why I am getting the error.

Thank you,

William






More information about the grass-stats mailing list