readRAST6 {spgrass6}R Documentation

Read and write GRASS 6 raster files

Description

Read GRASS 6 raster files from GRASS 6 into R SpatialGridDataFrame objects, and write single columns of R SpatialGridDataFrame objects to GRASS 6. readRAST6 and writeRAST6 use temporary binary files and r.out.bin and r.in.bin rather than the temporary ASCII files used in earlier implementations. The earlier versions may still be used in a transition period.

Usage

readRAST6(vname, cat=NULL, ignore.stderr = FALSE)
writeRAST6(x, vname, zcol = 1, NODATA=-9999, ignore.stderr = FALSE)

Arguments

vname A vector of GRASS 6.0 raster file names
cat default NULL; if not NULL, must be a logical vector matching vname, stating which (CELL) rasters to return as factor
ignore.stderr default FALSE, can be set to TRUE to silence system() output to standard error; does not apply on Windows platforms
x A SpatialGridDataFrame object for export to GRASS as a raster layer
zcol Attribute column number or name
NODATA NODATA value

Value

readRAST6 returns a SpatialGridDataFrame objects with an AttributeList in the data slots, and with the projection argument set.

Author(s)

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

Examples

if (nchar(Sys.getenv("GISRC")) > 0) {
  spear <- readRAST6(c("geology", "elevation.dem"), cat=c(TRUE, FALSE), ignore.stderr=TRUE)
  table(spear$geology)
  system("r.stats -q -cl geology")
  boxplot(spear$elevation.dem ~ spear$geology)
  spear$sqdem <- sqrt(spear$elevation.dem)
  writeRAST6(spear, "sqdemSP", zcol="sqdem", NODATA=-9999.99, ignore.stderr=TRUE)
  system("r.info sqdemSP")
  system("g.remove rast=sqdemSP")
}

[Package spgrass6 version 0.3-2 Index]