[STATSGRASS] R & GRASS inicialization.
Roger Bivand
Roger.Bivand at nhh.no
Fri Aug 2 06:56:40 EDT 2002
On Fri, 2 Aug 2002, andres javier garcia garcia wrote:
> Hello all;
> I've just installed the R interface to GRASS. (I'm new to R), and I'm not
> sure if it is properly installed.
> From GRASS y type R, and
> >system("g.list rast") shows my raster maps properly.
> Then I've tried to follow the steps indicated in Bivand, (2000). And typed
> >tapply(dem, cover,summary)
> (where dem is a Digital Elevation Model, and cover is a map of different
> clases of vegetal cover)
> and the following message appears:
> Object "cover" not found.
>
The interface expects you first to collect the grass metadata (current
region):
G <- gmeta()
You can then do
summary(G)
to check that it is OK.
I'm now assuming that you have a number of raster layers in GRASS, among
them dem and cover. I think you did:
dem <- rast.get(G, rlist=c("dem", "cover"), catlabels=c(FALSE, TRUE))
and tried to work on dem. If you do
str(dem)
you will see that it is a list with two members, dem and cover. To get at
the actual data, you need say:
myrasts <- rast.get(G, rlist=c("dem", "cover"), catlabels=c(FALSE, TRUE))
then
tapply(myrasts$dem, myrasts$cover,summary)
NB: for tapply() to work, cover needs to be a "factor" in R terminology.
To get some insight into the meaning of lists, factors, etc in R, Agus'
advice is the best way to go.
> I've tried the same with different location and mapsets and none works.
Please let us know how you get on!
Roger
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no
and: Department of Geography and Regional Development, University of
Gdansk, al. Mar. J. Pilsudskiego 46, PL-81 378 Gdynia, Poland.
More information about the grass-stats
mailing list