[Raster-commits] r354 - in pkg/raster: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Mar 14 07:16:00 CET 2009
Author: rhijmans
Date: 2009-03-14 07:16:00 +0100 (Sat, 14 Mar 2009)
New Revision: 354
Added:
pkg/raster/R/setFilename.R
pkg/raster/R/setRowCol.R
pkg/raster/man/filename.Rd
pkg/raster/man/setMinMax.Rd
pkg/raster/man/setNAvalue.Rd
pkg/raster/man/setProjection.Rd
pkg/raster/man/setRowCol.Rd
Removed:
pkg/raster/man/set.Rd
Modified:
pkg/raster/DESCRIPTION
pkg/raster/NAMESPACE
pkg/raster/R/Compare_Logical.R
pkg/raster/R/depracated.R
pkg/raster/R/raster.R
pkg/raster/R/set.R
pkg/raster/man/export.Rd
pkg/raster/man/rasterFromFile.Rd
pkg/raster/man/saveStack.Rd
pkg/raster/man/writeRaster.Rd
Log:
Modified: pkg/raster/DESCRIPTION
===================================================================
--- pkg/raster/DESCRIPTION 2009-03-14 04:11:47 UTC (rev 353)
+++ pkg/raster/DESCRIPTION 2009-03-14 06:16:00 UTC (rev 354)
@@ -1,8 +1,8 @@
Package: raster
Type: Package
Title: Raster data handling for geographic data analysis and modeling
-Version: 0.8.9-5
-Date: 9-March-2009
+Version: 0.8.9-6
+Date: 14-March-2009
Depends: methods, sp, rgdal (>= 0.5-33), R (>= 2.8.0)
Author: Robert J. Hijmans & Jacob van Etten
Maintainer: Robert J. Hijmans <r.hijmans at gmail.com>
Modified: pkg/raster/NAMESPACE
===================================================================
--- pkg/raster/NAMESPACE 2009-03-14 04:11:47 UTC (rev 353)
+++ pkg/raster/NAMESPACE 2009-03-14 06:16:00 UTC (rev 354)
@@ -4,5 +4,5 @@
importFrom("utils", stack, unstack)
importFrom("sp", overlay, bbox, Spatial, SpatialPixels, SpatialPixelsDataFrame, SpatialGrid, SpatialGridDataFrame)
exportClasses(BoundingBox, BasicRaster, Raster, RasterLayer, RasterStack)
-exportMethods(calc, overlay, bbox, aggregate, stack, unstack, show, summary, plot, hist, ncol, nrow, ncell, dim, lines, median)
+exportMethods(raster, calc, overlay, bbox, aggregate, stack, unstack, show, summary, plot, hist, ncol, nrow, ncell, dim, lines, median)
exportPattern("^[^\\.]")
\ No newline at end of file
Modified: pkg/raster/R/Compare_Logical.R
===================================================================
--- pkg/raster/R/Compare_Logical.R 2009-03-14 04:11:47 UTC (rev 353)
+++ pkg/raster/R/Compare_Logical.R 2009-03-14 06:16:00 UTC (rev 354)
@@ -68,7 +68,7 @@
if (canProcessInMemory(e1, 3)) {
rst <- setValues(rst, values=callGeneric(.getRasterValues(e1), rep(e2, ncell(e1)) ) )
} else {
- rst <- setFilename(rst, filename=tempfile())
+ rst <- setFilename(rst, value=tempfile())
rowrep <- rep(e2, ncol(e1))
for (r in 1:nrow(e1)) {
rst <- setValues(rst, callGeneric( .getRowValues(e1, r), rowrep ), r)
@@ -114,7 +114,7 @@
if (canProcessInMemory(e1, 3)) {
rst <- setValues(rst, callGeneric(.getRasterValues(e1), .getRasterValues(e2) ) )
} else {
- rst <- setFilename(rst, filename=tempfile())
+ rst <- setFilename(rst, value=tempfile())
for (r in 1:nrow(e1)) {
rst <- setValues(rst, callGeneric( .getRowValues(e1, r), .getRowValues(e2, r) ), r)
rst <- writeRaster(rst)
@@ -136,7 +136,7 @@
if (canProcessInMemory(e1, 3)) {
rst <- setValues(rst, callGeneric(.getLogicalValues(e1), .getLogicalValues(e2)))
} else {
- rst <- setFilename(rst, filename=tempfile())
+ rst <- setFilename(rst, value=tempfile())
for (r in 1:nrow(e1)) {
rst <- setValues(rst, callGeneric( .getLogicalRowValues(e1, r), .getLogicalRowValues(e2, r) ), r)
rst <- writeRaster(rst)
Modified: pkg/raster/R/depracated.R
===================================================================
--- pkg/raster/R/depracated.R 2009-03-14 04:11:47 UTC (rev 353)
+++ pkg/raster/R/depracated.R 2009-03-14 06:16:00 UTC (rev 354)
@@ -3,11 +3,25 @@
# stop("'newRaster' is deprecated. Use 'raster' instead")
#}
+setRaster <- function(object, filename="", values=NULL) {
+ warning('depracated, use "raster()" instead')
+ return(raster(x=object, filename=filename, values=values))
+}
+rasterFromBbox <- function(bndbox, nrows=10, ncols=10) {
+ warning("'rasterFromBbox' is deprecated. Use 'raster(bbox, ...)' instead")
+ return(raster(x=bndbox, nrows=nrows, ncols=ncols))
+}
+
+rasterFromFile <- function(filename, values=FALSE, band=1) {
+ warning("'rasterFromFile' is deprecated. Use 'raster(filename)' instead")
+ return(raster(x=filename, values=values, band=band))
+}
+
+
# no longer used. Use calc instead. See ?calc
-
...isNA <- function(raster, value=0, filename="", overwrite=FALSE, asInt=FALSE) {
fun <- function(x) { x[is.na(x)] <- value; return(x)}
if (asInt) { datatype <- 'INT4S' } else { datatype <- 'FLT4S' }
Modified: pkg/raster/R/raster.R
===================================================================
--- pkg/raster/R/raster.R 2009-03-14 04:11:47 UTC (rev 353)
+++ pkg/raster/R/raster.R 2009-03-14 06:16:00 UTC (rev 354)
@@ -3,23 +3,13 @@
# Date : June 2008
# Version 0.8
# Licence GPL v3
-
-
-rasterFromBbox <- function(bndbox, nrows=10, ncols=10) {
- warning("'rasterFromBbox' is deprecated. Use 'raster(bbox, ...)' instead")
- return(raster(bndbox=bndbox, nrows=nrows, ncols=ncols))
-}
-
-rasterFromFile <- function(filename, values=FALSE, band=1) {
- warning("'rasterFromFile' is deprecated. Use 'raster(filename)' instead")
- return(raster(filename, values=values, band=band))
-}
if (!isGeneric("raster")) {
setGeneric("raster", function(x, ...)
standardGeneric("raster"))
}
+
setMethod('raster', signature(x='missing'),
function(nrows=180, ncols=360, xmn=-180, xmx=180, ymn=-90, ymx=90, projs="+proj=longlat +datum=WGS84") {
bb <- newBbox(xmn, xmx, ymn, ymx)
@@ -28,6 +18,23 @@
}
)
+
+setMethod('raster', signature(x='character'),
+ function(x, values=FALSE, band=1) {
+ fileext <- toupper(fileExtension(x))
+ if ( fileext == ".GRD" | fileext == ".GRI" ) {
+ r <- .rasterFromRasterFile(x, band)
+ } else {
+ r <- .rasterFromGDAL(x, band)
+ }
+ if (values) {
+ r <- readAll(r)
+ }
+ return(r)
+ }
+)
+
+
setMethod('raster', signature(x='Raster'),
function(x, filename="", values=NULL) {
@@ -50,33 +57,18 @@
}
)
-setMethod('raster', signature(x='character'),
- function(x, values=FALSE, band=1) {
- fileext <- toupper(fileExtension(x))
- if ( fileext == ".GRD" | fileext == ".GRI" ) {
- r <- .rasterFromRasterFile(x, band)
- } else {
- r <- .rasterFromGDAL(x, band)
- }
- if (values) {
- r <- readAll(r)
- }
- return(r)
- }
-)
-
setMethod('raster', signature(x='BoundingBox'),
-function(x, nrows=10, ncols=10, projs='NA') {
- bb <- getBbox(x)
- nr = as.integer(round(nrows))
- nc = as.integer(round(ncols))
- if (nc < 1) { stop("ncols should be > 0") }
- if (nr < 1) { stop("nrows should be > 0") }
- rs <- new("RasterLayer", bbox=bb, ncols=nc, nrows=nr)
- rs <- setProjection(rs, projs)
- return(rs)
-}
+ function(x, nrows=10, ncols=10, projs='NA') {
+ bb <- getBbox(x)
+ nr = as.integer(round(nrows))
+ nc = as.integer(round(ncols))
+ if (nc < 1) { stop("ncols should be > 0") }
+ if (nr < 1) { stop("nrows should be > 0") }
+ r <- new("RasterLayer", bbox=bb, ncols=nc, nrows=nr)
+ r <- setProjection(r, projs)
+ return(r)
+ }
)
Modified: pkg/raster/R/set.R
===================================================================
--- pkg/raster/R/set.R 2009-03-14 04:11:47 UTC (rev 353)
+++ pkg/raster/R/set.R 2009-03-14 06:16:00 UTC (rev 354)
@@ -10,61 +10,14 @@
}
}
-setRowCol <- function(raster, nrows=nrow(raster), ncols=ncol(raster)) {
- raster <- clearValues(raster)
- raster at ncols <- as.integer(ncols)
- raster at nrows <- as.integer(nrows)
- return(raster)
-}
-setRes <- function(object, xres, yres=xres) {
- if (extends(class(object), "Raster")) {
- object <- clearValues(object)
- }
- bb <- getBbox(object)
- nc <- round( (bb at xmax - bb at xmin) / xres )
- nr <- round( (bb at ymax - bb at ymin) / yres )
- bb at xmax <- bb at xmin + nc * xres
- bb at ymin <- bb at ymax - nr * yres
- object <- setExtent(object, bb)
- object <- setRowCol(object, nr, nc)
- return(object)
-}
-
-setRaster <- function(object, filename="", values=NULL) {
- warning('depracated, use "raster()" instead')
- return(raster(object, filename, values))
-}
-
-setFilename <- function(object, filename) {
- if (is.na(filename)) {filename <- ""}
- filename <- trim(filename)
- if (class(object)=='RasterStack') {
- object at filename <- setFileExtension(filename, ".stk")
- } else {
- object at file@name <- filename
- }
- if (class(object)=='RasterLayer') {
- shortname <- shortFileName(filename)
- shortname <- setFileExtension(shortname, "")
- shortname <- gsub(" ", "_", shortname)
- if (nbands(object) > 1) { shortname <- paste(shortname, "_", band(object)) }
- object at file@shortname <- shortname
- object at file@gdalhandle <- list()
- }
- return(object)
-}
-
-
-
-
-setProjection <- function(object, projs) {
- if (class(projs)=="CRS") {
- object at crs <- projs
+setProjection <- function(x, value) {
+ if (class(value)=="CRS") {
+ x at crs <- value
} else {
- object at crs <- newCRS(projs)
+ x at crs <- newCRS(value)
}
- return(object)
+ return(x)
}
Added: pkg/raster/R/setFilename.R
===================================================================
--- pkg/raster/R/setFilename.R (rev 0)
+++ pkg/raster/R/setFilename.R 2009-03-14 06:16:00 UTC (rev 354)
@@ -0,0 +1,28 @@
+# Author: Robert J. Hijmans, r.hijmans at gmail.com
+# International Rice Research Institute
+# Date : June 2008
+# Version 0.8
+# Licence GPL v3
+
+
+
+setFilename <- function(x, value) {
+ filename <- value
+ if (is.na(filename)) {filename <- ""}
+ filename <- trim(filename)
+ if (class(x)=='RasterStack') {
+ x at filename <- setFileExtension(filename, ".stk")
+ } else {
+ x at file@name <- filename
+ }
+ if (class(x)=='RasterLayer') {
+ shortname <- shortFileName(filename)
+ shortname <- setFileExtension(shortname, "")
+ shortname <- gsub(" ", "_", shortname)
+ if (nbands(x) > 1) { shortname <- paste(shortname, "_", band(x)) }
+ x at file@shortname <- shortname
+ x at file@gdalhandle <- list()
+ }
+ return(x)
+}
+
Added: pkg/raster/R/setRowCol.R
===================================================================
--- pkg/raster/R/setRowCol.R (rev 0)
+++ pkg/raster/R/setRowCol.R 2009-03-14 06:16:00 UTC (rev 354)
@@ -0,0 +1,31 @@
+# Author: Robert J. Hijmans, r.hijmans at gmail.com
+# International Rice Research Institute
+# Date : June 2008
+# Version 0.8
+# Licence GPL v3
+
+setRowCol <- function(object, nrows=nrow(object), ncols=ncol(object)) {
+# to do: also remove file connection !
+ if (extends(class(object), "Raster")) {
+ object <- clearValues(object)
+ }
+ object at ncols <- as.integer(ncols)
+ object at nrows <- as.integer(nrows)
+ return(object)
+}
+
+setRes <- function(object, xres, yres=xres) {
+ if (extends(class(object), "Raster")) {
+ object <- clearValues(object)
+ }
+ bb <- getBbox(object)
+ nc <- round( (bb at xmax - bb at xmin) / xres )
+ nr <- round( (bb at ymax - bb at ymin) / yres )
+ bb at xmax <- bb at xmin + nc * xres
+ bb at ymin <- bb at ymax - nr * yres
+ object <- setExtent(object, bb)
+ object <- setRowCol(object, nr, nc)
+ return(object)
+}
+
+
Modified: pkg/raster/man/export.Rd
===================================================================
--- pkg/raster/man/export.Rd 2009-03-14 04:11:47 UTC (rev 353)
+++ pkg/raster/man/export.Rd 2009-03-14 06:16:00 UTC (rev 354)
@@ -37,7 +37,7 @@
r <- raster(system.file("external/test.ag", package="sp"))
r <- readAll(r)
-r <- setFilename(r, 'export.grd')
+filename(r) <- 'export.grd'
r <- writeRaster(r)
writeHeader(r, type="ENVI")
Added: pkg/raster/man/filename.Rd
===================================================================
--- pkg/raster/man/filename.Rd (rev 0)
+++ pkg/raster/man/filename.Rd 2009-03-14 06:16:00 UTC (rev 354)
@@ -0,0 +1,34 @@
+\name{filename}
+\alias{setFilename}
+\alias{filename<-}
+
+\title{ Set filename}
+
+\description{
+Set the filename of a Raster* object
+}
+
+\usage{
+setFilename(x, value)
+filename(x) <- value
+}
+
+\arguments{
+ \item{x}{A Raster* object }
+ \item{value}{filename, including path, can be an empty string \code{""} }
+}
+
+\value{
+a Raster* object
+}
+
+
+\author{ Robert J. Hijmans }
+
+\examples{
+r <- raster()
+filename(r) <- "c:/test.grd"
+}
+
+\keyword{ spatial }
+
Modified: pkg/raster/man/rasterFromFile.Rd
===================================================================
--- pkg/raster/man/rasterFromFile.Rd 2009-03-14 04:11:47 UTC (rev 353)
+++ pkg/raster/man/rasterFromFile.Rd 2009-03-14 06:16:00 UTC (rev 354)
@@ -1,7 +1,9 @@
\name{rasterFromFile}
+
\alias{rasterFromFile}
\alias{rasterFromBbox}
+\alias{setRaster}
\title{Raster from file}
@@ -12,16 +14,18 @@
\usage{
rasterFromFile(filename, values=FALSE, band=1)
rasterFromBbox(bndbox, nrows=10, ncols=10)
+setRaster(object, filename="", values=NULL)
}
\arguments{
\item{filename}{name of raster data file }
\item{band}{band number in case of a file of multiple bands, default = 1 }
- \item{values}{logical. If \code{TRUE}, RasterLayer values will be read into memory with 'readAll()'}
+ \item{values}{logical. If \code{TRUE}, RasterLayer values will be read into memory with 'readAll()'; or the values to associate with the RasterLayer object }
\item{bndbox}{a BoundingBox object}
\item{nrows}{number of rows on raster }
\item{ncols}{number of columns on raster }
+ \item{object}{A Raster* object }
}
Modified: pkg/raster/man/saveStack.Rd
===================================================================
--- pkg/raster/man/saveStack.Rd 2009-03-14 04:11:47 UTC (rev 353)
+++ pkg/raster/man/saveStack.Rd 2009-03-14 06:16:00 UTC (rev 354)
@@ -5,8 +5,9 @@
\title{ Save or open a RasterStack file }
\description{
- A RasterStack is a collection of rasters with the same spatial extent and resolution. They can be crated from RasterLayer objects, or from raster files.
- These two functions allow you to save the references to raster files and recreate a rasterStack object later. The values are not saved, only the references to the files.
+A RasterStack is a collection of rasters with the same spatial extent and resolution. They can be crated from RasterLayer objects,
+or from raster files. These two functions allow you to save the references to raster files and recreate a rasterStack object later.
+The values are not saved, only the references to the files.
}
\usage{
@@ -29,14 +30,14 @@
\author{Robert J. Hijmans}
-\seealso{ \code{\link[raster]{stack}}, \code{\link[raster]{changeStack}}}
+\seealso{ \code{\link[raster]{filename}}, \code{\link[raster]{stack}}, \code{\link[raster]{changeStack}}}
\examples{
rasterfile <- system.file("external/test.ag", package="sp")
st <- stackFromFiles(c(rasterfile, rasterfile))
- st <- setFilename(st, "mystack")
+ filename(st) <- "mystack"
st <- stackSave(st)
-# note that setFilename adds an extension .stk to a stackfile
+# note that filename adds an extension .stk to a stackfile
st2 <- stackOpen("mystack.stk")
st2
}
Deleted: pkg/raster/man/set.Rd
===================================================================
--- pkg/raster/man/set.Rd 2009-03-14 04:11:47 UTC (rev 353)
+++ pkg/raster/man/set.Rd 2009-03-14 06:16:00 UTC (rev 354)
@@ -1,73 +0,0 @@
-\name{set}
-\alias{setRaster}
-\alias{setFilename}
-\alias{filename<-}
-\alias{setProjection}
-\alias{projection<-}
-\alias{setRowCol}
-\alias{ncol<-}
-\alias{nrow<-}
-\alias{setRes}
-\alias{resolution<-}
-\alias{setMinMax}
-\alias{setNAvalue}
-
-\title{ Set properties of a RasterLayer }
-
-\description{
-Use these functions to set certain properties of a RasterLayer object.
-}
-
-\usage{
-setProjection(object, projs)
-setFilename(object, filename)
-setRaster(object, filename="", values=NULL)
-setRowCol(raster, nrows=nrow(raster), ncols=ncol(raster))
-setRes(object, xres, yres=xres)
-setMinMax(raster)
-setNAvalue(raster, value)
-}
-
-\arguments{
- \item{object}{A Raster* object }
- \item{raster}{ A \code{RasterLayer} object }
- \item{values}{ Data values to associate with the RasterLayer object }
- \item{filename}{ filename, can be blank }
- \item{nrows}{ the new number of rows for the raster }
- \item{ncols}{ the new number of cols for the raster }
- \item{xres}{ the new x resolution}
- \item{yres}{ the new y resolution}
- \item{projs}{a character string describing a projection and datum in PROJ4 format }
- \item{value}{the value to be interpreted as NA; set this before reading the values from the file. Integer values are matched exactely; for decimal values files any value <= the value will be interpreted as NA}
-}
-
-\details{
-While you could access the slots of the object directly, you would do that at your own peril because the value of one raster property can affect values in other properties, and changing slot values may thus break the integrity of the objects. Using slots directly may also lead to code to break in the future if underlying class definitions change.
-}
-
-\value{
-a Raster* object
-}
-
-\seealso{ \code{\link[raster]{extent}}, \code{\link[raster]{dimensions}} }
-
-\author{ Robert J. Hijmans }
-
-\examples{
-r <- raster()
-r <- setRowCol(r, nrows=18, ncols=36)
-# equivalent to
-nrow(r) <- 18
-ncol(r) <- 36
-r <- setRes(r, xres=1/120)
-# equivalent to
-resolution(r) <- 1/120
-# set yres diffrently
-resolution(r) <- c(1/120, 1/60)
-r <- setProjection(r, "+proj=longlat +datum=WGS84")
-r <- setFilename(r, "c:/test.grd")
-
-}
-
-\keyword{ spatial }
-
Added: pkg/raster/man/setMinMax.Rd
===================================================================
--- pkg/raster/man/setMinMax.Rd (rev 0)
+++ pkg/raster/man/setMinMax.Rd 2009-03-14 06:16:00 UTC (rev 354)
@@ -0,0 +1,35 @@
+\name{set}
+\alias{setMinMax}
+
+\title{Set extreme values }
+
+\description{
+The minimum and maximum value of a RasterLayer are computed from a file in disk and stored in the resulting RasterLayer object.
+}
+
+\usage{
+setMinMax(raster)
+}
+
+\arguments{
+ \item{raster}{ A \code{RasterLayer} object }
+}
+
+\value{
+a Raster* object
+}
+
+\seealso{ \code{\link[raster]{values}} }
+
+\author{ Robert J. Hijmans }
+
+\examples{
+r <- raster(system.file("pictures/Rlogo.jpg", package="rgdal"))
+r
+r <- setMinMax(r)
+r
+
+}
+
+\keyword{ spatial }
+
Added: pkg/raster/man/setNAvalue.Rd
===================================================================
--- pkg/raster/man/setNAvalue.Rd (rev 0)
+++ pkg/raster/man/setNAvalue.Rd 2009-03-14 06:16:00 UTC (rev 354)
@@ -0,0 +1,38 @@
+\name{setNAvalue}
+
+\alias{setNAvalue}
+
+\title{set the NA value of a RasterLayer }
+
+\description{
+If you set the NA value of a RasterLayer, this value will be interpreted as NA when reading the values from a file.
+Values already in memory will not be affected.
+}
+
+\usage{
+setNAvalue(raster, value)
+}
+
+\arguments{
+ \item{raster}{ A \code{RasterLayer} object }
+ \item{value}{the value to be interpreted as NA; set this before reading the values from the file. Integer values are matched exactely; for decimal values files any value <= the value will be interpreted as NA}
+}
+
+
+\value{
+a Raster* object
+}
+
+
+\author{ Robert J. Hijmans }
+
+\examples{
+r1 <- raster(system.file("pictures/Rlogo.jpg", package="rgdal"))
+r2 <- setNAvalue(r1, 255)
+#plot(r1)
+#x11()
+#plot(r2)
+}
+
+\keyword{ spatial }
+
Added: pkg/raster/man/setProjection.Rd
===================================================================
--- pkg/raster/man/setProjection.Rd (rev 0)
+++ pkg/raster/man/setProjection.Rd 2009-03-14 06:16:00 UTC (rev 354)
@@ -0,0 +1,37 @@
+\name{setProjection}
+\alias{setProjection}
+\alias{projection<-}
+
+\title{ Set projection }
+
+\description{
+Set the map projection of a Raster* object
+}
+
+\usage{
+setProjection(x, value)
+projection(x) <- value
+}
+
+\arguments{
+ \item{x}{A Raster* object }
+ \item{value}{a CRS object or a character string describing a projection and datum in PROJ4 format }
+}
+
+
+\value{
+a Raster* object
+}
+
+\seealso{ \code{\link[raster]{project}, \link[rgdal]{CRS-class}, \link[rgdal]{projInfo}}}
+
+\author{ Robert J. Hijmans }
+
+\examples{
+r <- raster()
+r <- setProjection(r, "+proj=lcc +lat_1=48 +lat_2=33 +lon_0=-100 +ellps=WGS84")
+
+}
+
+\keyword{ spatial }
+
Added: pkg/raster/man/setRowCol.Rd
===================================================================
--- pkg/raster/man/setRowCol.Rd (rev 0)
+++ pkg/raster/man/setRowCol.Rd 2009-03-14 06:16:00 UTC (rev 354)
@@ -0,0 +1,63 @@
+\name{setRowCol}
+
+\alias{setRowCol}
+\alias{ncol<-}
+\alias{nrow<-}
+\alias{setRes}
+\alias{resolution<-}
+
+\title{ Set properties of a RasterLayer }
+
+\description{
+Use these functions to set certain properties of a RasterLayer object.
+}
+
+\usage{
+setRowCol(object, nrows=nrow(object), ncols=ncol(object))
+ncol(x) <- value
+nrow(x) <- value
+setRes(object, xres, yres=xres)
+resolution(x) <- value
+}
+
+\arguments{
+ \item{object}{A Raster* object }
+ \item{x}{A Raster* object }
+ \item{nrows}{ the new number of rows for the raster }
+ \item{ncols}{ the new number of cols for the raster }
+ \item{xres}{ the new x resolution}
+ \item{yres}{ the new y resolution}
+ \item{value}{depends on context. Can be row or column number or resolution }
+}
+
+\details{
+While you could set these values by accessing the slots of the Raster* object directly,
+you would do that at your own peril because the value of one raster property can affect values in other properties,
+and changing slot values may thus break the integrity of the objects. Using slots directly may also lead to code
+to break in the future if underlying class definitions change.
+}
+
+\value{
+a Raster* object
+}
+
+\seealso{ \code{\link[raster]{extent}}, \code{\link[raster]{dimensions}} }
+
+\author{ Robert J. Hijmans }
+
+\examples{
+r <- raster()
+r <- setRowCol(r, nrows=18, ncols=36)
+# equivalent to
+nrow(r) <- 18
+ncol(r) <- 36
+r <- setRes(r, xres=1/120)
+# equivalent to
+resolution(r) <- 1/120
+# set yres diffrently
+resolution(r) <- c(1/120, 1/60)
+
+}
+
+\keyword{ spatial }
+
Modified: pkg/raster/man/writeRaster.Rd
===================================================================
--- pkg/raster/man/writeRaster.Rd 2009-03-14 04:11:47 UTC (rev 353)
+++ pkg/raster/man/writeRaster.Rd 2009-03-14 06:16:00 UTC (rev 354)
@@ -54,21 +54,21 @@
rs <- readAll(rs)
# write all to a new binary file
-rs <- setFilename(rs, "binall.grd")
+filename(rs) <- "binall.grd"
rs <- writeRaster(rs, overwrite=TRUE)
# write all to a new ERDAS .img file
-rs <- setFilename(rs, "binall.img")
+filename(rs) <- "binall.img"
rs <- writeRaster(rs, filetype="HFA", overwrite=TRUE)
# write all to integer binary file
-rs <- setFilename(rs, "binallint.grd")
+filename(rs) <- "binallint.grd"
rs <- setDatatype(rs, "INT4S")
rs <- writeRaster(rs, overwrite=TRUE)
# write all to ascii file
-rs <- setFilename(rs, "ascall.asc")
+filename(rs) <- "ascall.asc"
rs <- writeRaster(rs, filetype='ascii', overwrite=TRUE)
# read and write row by row; write to ascii file
More information about the Raster-commits
mailing list