[STATSGRASS] Problems understanding how to use Rpy ( a Python module) to access
GRASS rasters in R
William Hudspeth
bhudspeth at edac.unm.edu
Thu Feb 17 10:24:05 EST 2005
Hello,
I have previously used BASH shell scripts to successfully pass GRASS
raster data sets to R, and then run basic statistics and plotting
functions. Now, I am using Rpy 0.4.0 in an application that loads the
GRASS GIS library. Prior to calling Rpy functions, I make sure to use
Python to set up all of my environmental variables. I am then able to
use code such as you see below to load my GRASS location metadata into
Python objects:
r_results=r.library('GRASS')
G=r.gmeta()
maps=r.get_mapsets()
raster_layers=r.list_grass(type="cell")
I understand that the variables on the left are Python objects - I can
print out correct locational values to screen. However, if I want to
summarize and plot the values in a certain raster map layer, I know that
I probably need to create an R object first. It is not clear to me how I
go about doing this given what I have read in the Rpy documentation. I
have tried to move a raster into a Python object as such:
elev=r.rast_get(G,"elevation")
but, this fails with the error
sh: line 1: rm command not found
In short, it is unclear how I go about using the GRASS R libary
functions through Rpy. I can run some of the library functions and
create Python objects, but don't get how to create analogous objects in
R and work with them. I am ultimately interested in working with raster
layers and generating basic statistics and plots.
Any sample code or guidance would help.
Bill
More information about the grass-stats
mailing list