[STATSGRASS] Problems using rast.get() in a script
Roger Bivand
Roger.Bivand at nhh.no
Tue Sep 13 02:47:53 EDT 2005
On Mon, 12 Sep 2005, William Hudspeth wrote:
> 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.
Please try GRASS 0.2-24, 0.2-2 is very old, and certainly pre-dates
changes avoiding the caching of the Cell_head window structure in
libgis.a.
>
> 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.
>
Please don't say "crash", that suggests a malfunction. The error message
is from line 54 in the current src/rastget.c, and if your copy of the
source file doesn't have the preceding comment:
/* G_get_window(&cellhd); calls G_fatal_error internally */
then the problem has been identified and solved. If not, then more details
are needed.
Roger
> Thank you,
>
> William
>
>
>
> _______________________________________________
> statsgrass mailing list
> statsgrass at grass.itc.it
> http://grass.itc.it/mailman/listinfo/statsgrass
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, 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