rast.get {GRASS}R Documentation

Import GRASS raster files

Description

rast.get() moves one or more GRASS 5.0 raster files to a list, returning the filled object. Setting catlabels elements, corresponding to the files named in rlist, to TRUE, imports category labels instead of codes yielding an ordered factor rather than a numeric vector, and requires more memory.

Usage

rast.get(G, rlist="", catlabels=NULL, drop.unused.levels=FALSE, 
        make.ordered=TRUE, debug=FALSE, interp=FALSE)

Arguments

G GRASS metadata from gmeta()
rlist character vector of GRASS raster file names; may include mapset qualifiers
catlabels logical vector of length length(rlist): if TRUE, GRASS category raster layers are imported as ordered factors, if FALSE, as numeric only
drop.unused.levels default FALSE, if TRUE, drop unused levels from factor. Beware: some levels may be absent from a region of a location but should be retained, use TRUE with caution. The argument will be applied to all layers read during a single call to read.get().
make.ordered The default behaviour has been to treat all GRASS categorical rasters as ordered factors. This can be modified by setting to FALSE, when the "ordered" class tag will be removed. The argument will be applied to all layers read during a single call to read.get().
debug if TRUE, the temporary ASCII file used for transfer is not deleted on exit from the function
interp if TRUE, the interpreted version of the function is used instead of the loaded compiled version

Details

rast.get() assumes firstly that the region of the GRASS LOCATION has not been changed since gmeta() was last run, secondly that resolutions of the requested map layers and the GRASS LOCATION are in accord, and thirdly that the data cover the selected region. If the second or third assumptions are not met for the interpreted version, the GRASS program r.stats run through system() will read from the underlying map layers according to the new region setting, yielding cell values at the current resolution, and inserting NAs in areas for which there are no data. For the compiled version, the user is required to work within a given map region at the same resolution.

Value

A list is returned with length(rlist) vectors and G$Ncells values in each vector; the columns are named using the names of the imported GRASS raster files. If the names of the GRASS raster files are qualified by mapset, the name of the mapset will be appended after an underscore. Those imported with category labels are ordered factors, and their names are suffixed with .f

Note

The functions in this package are intended to work with the GRASS geographical information system. The examples for wrapper functions will will work whether or not R is running in GRASS, and whether or not the current location is that of the data set used for the examples. Examples of interface functions will however (from version 0.2-2) only work outside GRASS, to avoid possible overwriting of GRASS database locations and/or files.

Author(s)

Roger S. Bivand, e-mail: Roger.Bivand@nhh.no.

References

http://grass.itc.it/statsgrass/index.html, Bivand, R. S., (2000) Using the R statistical data analysis language on GRASS 5.0 GIS data base files. Computers and Geosciences, 26, pp. 1043-1052.

See Also

rast.put

Examples

if(!get("maas.loc", env = .GRASS.meta)) make.maas.location()
data(utm.maas)
Zn.o <- as.ordered(cut(utm.maas$Zn, labels=c("insignificant", "low",
"medium", "high", "crisis"), breaks=c(100, 200, 400, 700, 1000, 2000), 
include.lowest=TRUE))
G <- gmeta()
if(length(ls(pat="nameR"))==0){example(rast.put)}
exget <- rast.get(G, rlist=c("ex.Zn.grid.in", "ex.tr3.in",
  "ex.Zn.grid.o.in"), catlabels=as.logical(c(FALSE, FALSE, TRUE)))
oldpar <- par(mfrow=c(1,2))
plot(G, exget$ex.Zn.grid.in)
points(utm.maas$east, utm.maas$north, pch=18)
title("Bicubic spline interpolation")
plot(G, exget$ex.tr3.in)
points(utm.maas$east, utm.maas$north, pch=18)
title("Cubic trend surface")
par(oldpar)
table(exget$ex.Zn.grid.o.in)

[Package GRASS version 0.3-7 Index]