[Raster-commits] r305 - in pkg/raster: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Mar 3 11:07:39 CET 2009


Author: rhijmans
Date: 2009-03-03 11:07:38 +0100 (Tue, 03 Mar 2009)
New Revision: 305

Added:
   pkg/raster/R/cellValues.R
   pkg/raster/R/replaceProperties.R
   pkg/raster/R/xyValues.R
   pkg/raster/man/RasterLayer-class.Rd
   pkg/raster/man/Replace-methods.Rd
   pkg/raster/man/cellValues-methods.Rd
   pkg/raster/man/xyValues-methods.Rd
Removed:
   pkg/raster/man/cell.values.Rd
Modified:
   pkg/raster/DESCRIPTION
   pkg/raster/R/distance.R
   pkg/raster/R/overlay.R
   pkg/raster/R/read.generic.R
   pkg/raster/R/replacement.R
   pkg/raster/R/sOverlay.R
   pkg/raster/man/Logic-methods.Rd
   pkg/raster/man/cellsFromBbox.Rd
   pkg/raster/man/classes.Rd
   pkg/raster/man/coerce.Rd
   pkg/raster/man/overlay-methods.Rd
Log:


Modified: pkg/raster/DESCRIPTION
===================================================================
--- pkg/raster/DESCRIPTION	2009-03-03 06:54:10 UTC (rev 304)
+++ pkg/raster/DESCRIPTION	2009-03-03 10:07:38 UTC (rev 305)
@@ -1,7 +1,7 @@
 Package: raster
 Type: Package
 Title: Raster data handling for geographic data analysis and modeling
-Version: 0.8.8-9
+Version: 0.8.8-10
 Date: 3-March-2009
 Depends: methods, sp, rgdal (>= 0.5-33), R (>= 2.8.0)
 Author: Robert J. Hijmans & Jacob van Etten

Added: pkg/raster/R/cellValues.R
===================================================================
--- pkg/raster/R/cellValues.R	                        (rev 0)
+++ pkg/raster/R/cellValues.R	2009-03-03 10:07:38 UTC (rev 305)
@@ -0,0 +1,29 @@
+# Author: Robert J. Hijmans
+# International Rice Research Institute. Philippines
+# contact: r.hijmans at gmail.com
+# Date : November 2008
+# Version 0.8
+# Licence GPL v3
+
+
+###   cellValues   ###
+
+if (!isGeneric("cellValues")) {
+	setGeneric("cellValues", function(x, cells)
+		standardGeneric("cellValues"))
+}
+
+	
+setMethod("cellValues", signature(x='RasterLayer', cells='vector'), 
+	function(x, cells) { 
+		return(.rasterReadCells(x, cells))
+	}
+)
+
+
+setMethod("cellValues", signature(x='RasterStack', cells='vector'), 
+	function(x, cells) { 
+		return(.stackReadCells(x, cells))
+	}
+)
+

Modified: pkg/raster/R/distance.R
===================================================================
--- pkg/raster/R/distance.R	2009-03-03 06:54:10 UTC (rev 304)
+++ pkg/raster/R/distance.R	2009-03-03 10:07:38 UTC (rev 305)
@@ -84,7 +84,8 @@
 						newValues <- pmin(transitionValues,rowWindow[index])
 						if(newValues != rowWindow[index]){remainingCells<-TRUE}
 						rowWindow[index] 
-						outRaster <- setValues(outRaster, rowValues, startRow)
+						# startRow is undefined
+						# outRaster <- setValues(outRaster, rowValues, startRow)
 						outRaster <- writeRaster(outRaster, overwrite=TRUE)
 						if(r>1){rowWindow <- rowWindow[-1:ncols]}
 					}
@@ -112,7 +113,8 @@
 						newValues <- pmin(transitionValues,rowWindow[index])
 						if(newValues != rowWindow[index]){remainingCells<-TRUE}
 						rowWindow[index] 
-						outRaster <- setValues(outRaster, rowValues, startRow)
+						# startRow is undefined
+						#outRaster <- setValues(outRaster, rowValues, startRow)
 						outRaster <- writeRaster(outRaster, overwrite=TRUE)
 						if(r>1){rowWindow <- rowWindow[-1:ncols]}
 					}

Modified: pkg/raster/R/overlay.R
===================================================================
--- pkg/raster/R/overlay.R	2009-03-03 06:54:10 UTC (rev 304)
+++ pkg/raster/R/overlay.R	2009-03-03 10:07:38 UTC (rev 305)
@@ -5,15 +5,16 @@
 # Licence GPL v3
 
 
+
+setMethod('overlay', signature(x='RasterLayer', y='missing'), 
+function(x, y, fun=sum, filename="", overwrite=FALSE, filetype='raster', datatype='FLT4S', track=-1){ 
+	return(calc(x, fun=fun, overwrite=overwrite, filetype=filetype, datatype=datatype, track=track))
+}
+)
+
+
 setMethod('overlay', signature(x='RasterLayer', y='RasterLayer'), 
 function(x, y, ..., fun=sum, filename="", overwrite=FALSE, filetype='raster', datatype='FLT4S', track=-1){ 
-
-	if (missing(fun)) { stop("you must supply a function 'fun'. E.g., 'fun=function(x,y){return(x+y)}'") }
-	if (missing(filename)) { filename <- "" }
-	if (missing(overwrite)) { overwrite <- FALSE }
-	if (missing(datatype)) {datatype='FLT4S'}
-	if (missing(track)) {track=-1}
-	
 	rasters <- c(x, y)
 	obs <- list(...)
 	if (isTRUE(length(obs) > 0)) {
@@ -25,23 +26,38 @@
 			}
 		}
 	}
+	return(overlay(rasters, fun=fun, overwrite=overwrite, filetype=filetype, datatype=datatype, track=track))
+}
+)
+
+
+
+setMethod('overlay', signature(x='list', y='missing'), 
+function(x, y, fun=sum, filename="", overwrite=FALSE, filetype='raster', datatype='FLT4S', track=-1){ 
+	if (missing(fun)) { stop("you must supply a function 'fun'. E.g., 'fun=function(x,y){return(x+y)}'") }
+	if (missing(filename)) { filename <- "" }
+	if (missing(overwrite)) { overwrite <- FALSE }
+	if (missing(datatype)) {datatype='FLT4S'}
+	if (missing(track)) {track=-1}
 	
-	compare(c(x, rasters))
+	compare(x)
 
-	outraster <- setRaster(x, filename)
+	outraster <- setRaster(x[[1]], filename)
 	outraster <- setDatatype(outraster, datatype) 
 
 	inram <- TRUE
-	for (i in 1:length(rasters)) {
-		if (dataContent(rasters[[i]]) != 'all') {inram <- FALSE} 
+	for (i in 1:length(x)) {
+		if (dataContent(x[[i]]) != 'all') {
+			inram <- FALSE
+		} 
 	}	
 	
 	vallist <- list()
 
 	if ( inram ) {
-		for (i in 1:length(rasters)) {
-			vallist[[i]] <- values(rasters[[i]])
-			clearValues(rasters[[i]])
+		for (i in 1:length(x)) {
+			vallist[[i]] <- values(x[[i]])
+			clearValues(x[[i]])
 		}
 		vals <- do.call(fun, vallist)
 		
@@ -64,16 +80,16 @@
 		starttime <- proc.time()
 
 		for (r in 1:nrow(outraster)) {
-			for (i in 1:length(rasters)) {
-				if (dataSource(rasters[[i]]) == 'ram') {
-					rasters[i] <- valuesRow(rasters[[i]], r)
+			for (i in 1:length(x)) {
+				if (dataSource(x[[i]]) == 'ram') {
+					x[i] <- valuesRow(x[[i]], r)
 				} else {	
-					rasters[i] <- readRow(rasters[[i]], r)
+					x[i] <- readRow(x[[i]], r)
 				}	
 			}	
 			
-			for (i in 1:length(rasters)) {
-				vallist[[i]] <- values(rasters[[i]])
+			for (i in 1:length(x)) {
+				vallist[[i]] <- values(x[[i]])
 			#	clearValues(rasters[[i]])
 			}
 			vals <- do.call(fun, vallist)
@@ -101,6 +117,7 @@
 		}
 	} 
 	return(outraster)
+
+	
 }
 )
-

Modified: pkg/raster/R/read.generic.R
===================================================================
--- pkg/raster/R/read.generic.R	2009-03-03 06:54:10 UTC (rev 304)
+++ pkg/raster/R/read.generic.R	2009-03-03 10:07:38 UTC (rev 305)
@@ -80,74 +80,3 @@
 		return( .stackRead(object, rownr, startcol, ncolumns) ) }
 )
 
-
-###   cellValues   ###
-
-if (!isGeneric("cellValues")) {
-	setGeneric("cellValues", function(object, cells)
-		standardGeneric("cellValues"))
-}	
-	
-setMethod("cellValues", signature(object='RasterLayer', cells='vector'), 
-	function(object, cells) { 
-		return(.rasterReadCells(object, cells))
-	}
-)
-
-
-setMethod("cellValues", signature(object='RasterStack', cells='vector'), 
-	function(object, cells) { 
-		return(.stackReadCells(object, cells))
-	}
-)
-
-
-###   xyValues   ###
-
-if (!isGeneric("xyValues")) {
-	setGeneric("xyValues", function(object, xyCoords)
-		standardGeneric("xyValues"))
-}	
-	
-setMethod("xyValues", signature(object='RasterLayer', xyCoords='matrix'), 
-	function(object, xyCoords) { 
-		if (dim(xyCoords)[2] != 2) {
-			stop('xyCoords has wrong dimensions; there should be 2 columns only' )
-		}
-		cells <- cellFromXY(object, xyCoords)
-		return(.rasterReadCells(object, cells))
-	}	
-)	
-
-
-setMethod("xyValues", signature(object='RasterStack', xyCoords='matrix'), 
-	function(object, xyCoords) { 
-		if (dim(xyCoords)[2] != 2) {
-			stop('xyCoords has wrong dimensions; there should be 2 columns only' )
-		}
-		cells <- cellFromXY(object, xyCoords)
-		return(.stackReadCells(object, cells))
-	}	
-)
-
-
-
-setMethod("xyValues", signature(object='RasterStack', xyCoords='SpatialPoints'), 
-	function(object, xyCoords) { 
-		xyCoords <- coordinates(xyCoords)
-		cells <- cellFromXY(object, xyCoords)
-		return(.stackReadCells(object, cells))
-	}	
-)
-
-
-setMethod("xyValues", signature(object='RasterStack', xyCoords='SpatialPoints'), 
-	function(object, xyCoords) { 
-		xyCoords <- coordinates(xyCoords)
-		cells <- cellFromXY(object, xyCoords)
-		return(.stackReadCells(object, cells))
-	}	
-)
-
-
-

Added: pkg/raster/R/replaceProperties.R
===================================================================
--- pkg/raster/R/replaceProperties.R	                        (rev 0)
+++ pkg/raster/R/replaceProperties.R	2009-03-03 10:07:38 UTC (rev 305)
@@ -0,0 +1,51 @@
+# Author: Robert J. Hijmans, r.hijmans at gmail.com
+# International Rice Research Institute
+# Date :  January 2009
+# Version 0.8
+# Licence GPL v3
+
+
+'filename<-' <- function(x, value) {
+	return( setFilename(x, value) )
+}
+
+'datatype<-' <- function(x, value) {
+	return( setDatatype(x, value) )
+}
+
+'projection<-' <- function(x, value) {
+	return( setProjection(x, value) )
+}
+
+'ncol<-' <- function(x, value) {
+	return( setRowCol(x, ncols=value) )
+}	
+
+'nrow<-' <- function(x, value) {
+	return( setRowCol(x, nrows=value) )
+}	
+
+'resolution<-' <- function(x, value) {
+	if (length(value) == 1) {
+		return( setRes(x, xres=value, yres=value) )
+	} else {
+		return( setRes(x, xres=value[1], yres=value[2]) )
+	}
+}
+
+'xmin<-' <- function(x, value) {
+	return(changeBbox(x, xmn=value))
+}
+
+'xmax<-' <- function(x, value) {
+	return(changeBbox(x, xmx=value))
+}
+
+'ymin<-' <- function(x, value) {
+	return(changeBbox(x, ymn=value))
+}
+
+'ymax<-' <- function(x, value) {
+	return(changeBbox(x, ymx=value))
+}
+

Modified: pkg/raster/R/replacement.R
===================================================================
--- pkg/raster/R/replacement.R	2009-03-03 06:54:10 UTC (rev 304)
+++ pkg/raster/R/replacement.R	2009-03-03 10:07:38 UTC (rev 305)
@@ -4,72 +4,26 @@
 # Version 0.8
 # Licence GPL v3
 
-'filename<-' <- function(x, value) {
-	return( setFilename(x, value) )
-}
 
-'datatype<-' <- function(x, value) {
-	return( setDatatype(x, value) )
-}
 
-'projection<-' <- function(x, value) {
-	return( setProjection(x, value) )
-}
 
-'ncol<-' <- function(x, value) {
-	return( setRowCol(x, ncols=value) )
-}	
-
-'nrow<-' <- function(x, value) {
-	return( setRowCol(x, nrows=value) )
-}	
-
-'resolution<-' <- function(x, value) {
-	if (length(value) == 1) {
-		return( setRes(x, xres=value, yres=value) )
-	} else {
-		return( setRes(x, xres=value[1], yres=value[2]) )
-	}
-}
-
-'xmin<-' <- function(x, value) {
-	return(changeBbox(x, xmn=value))
-}
-
-'xmax<-' <- function(x, value) {
-	return(changeBbox(x, xmx=value))
-}
-
-'ymin<-' <- function(x, value) {
-	return(changeBbox(x, ymn=value))
-}
-
-'ymax<-' <- function(x, value) {
-	return(changeBbox(x, ymx=value))
-}
-
-
-.getColValues <- function(r, colnr) {
-	firstcol <- 1:nrow(r) * ncol(r) - ncol(r) 
-	cells <- colnr + firstcol 
-	return(values(r)[cells])
-}
-
-
-
 setMethod("[", "RasterLayer",
 	function(x,i,j,...,drop=FALSE) {
 		if (!missing(j)) { stop("incorrect number of dimensions") }
 # consider row, sparse....		
-		if (dataContent(x) != 'all') {
-			if (dataSource(x) != 'disk') {
-				stop('no data associated with this RasterLayer object')
+		if (missing(i)) { 
+			if (dataContent(x) == 'all') {
+				return(values(x)) 
 			} else {
-				return(cellValues(x, i))
+				if (dataSource(x) != 'disk') {
+					stop('no data associated with this RasterLayer object')
+				} else {
+					return(values(readAll(x)))
+				}	
 			}	
 		} else {
-			return(values(x)[i]) 
-		}	
+			return(cellValues(x, i))
+		}
 	}
 )
 
@@ -112,6 +66,13 @@
 )
 
 
+
+#.getColValues <- function(r, colnr) {
+#	firstcol <- 1:nrow(r) * ncol(r) - ncol(r) 
+#	cells <- colnr + firstcol 
+#	return(values(r)[cells]) }
+
+
 setMethod("[[", c("RasterLayer","ANY","ANY"),
 # i = row
 # j = col

Modified: pkg/raster/R/sOverlay.R
===================================================================
--- pkg/raster/R/sOverlay.R	2009-03-03 06:54:10 UTC (rev 304)
+++ pkg/raster/R/sOverlay.R	2009-03-03 10:07:38 UTC (rev 305)
@@ -1,13 +1,41 @@
+# Author: Robert J. Hijmans and Reinhard Krug
+# International Rice Research Institute
+# Date :  June 2008
+# Version 0.8
+# Licence GPL v3
 
 
+
 setMethod('overlay', signature(x='RasterStack', y='missing'), 
 function(x, y, fun, indices=1:nlayers(x), filename="", overwrite=FALSE, filetype='raster', datatype='FLT4S', track=-1){ 
-
+	
+	indices <- round(indices)
+	if (min(indices) < 1) {	stop('indices should be >= 1') }
+	if (max(indices) > nlayers(x)) {	stop('indices should be <= nlayers(x)') }
+	
+	rasters <- list()
+	for (i in 1:length(indices)) {
+		rasters[i] <- asRasterLayer(x, indices[i])
+	}
+	
 	if (missing(fun)) { 
 		stop("you must supply a function 'fun'. E.g., 'fun=function(x,y){return(x+y)}'") 
 	}
-
-	warning('not implemented yet')
+	
+	if (length(fun) == 1) {
+		return(overlay(rasters, fun=fun, overwrite=overwrite, filetype=filetype, datatype=datatype, track=track))
+	} else {
+		if (filename != "" &&  (length(filename) != length(fun)) ) {
+			stop('you must provide a filename for each function if you provide multiple functions')
+		}
+		
+		# the idea is to optimize this, by reading all (row) data only once.... 
+		res <- list()
+		for (i in 1:length(fun)) {
+			res[i] <- (overlay(rasters, fun=fun, overwrite=overwrite, filetype=filetype, datatype=datatype, track=track))
+		}
+		return(res)
+	}
 }
 )
 

Added: pkg/raster/R/xyValues.R
===================================================================
--- pkg/raster/R/xyValues.R	                        (rev 0)
+++ pkg/raster/R/xyValues.R	2009-03-03 10:07:38 UTC (rev 305)
@@ -0,0 +1,54 @@
+# Author: Robert J. Hijmans
+# International Rice Research Institute. Philippines
+# contact: r.hijmans at gmail.com
+# Date : November 2008
+# Version 0.8
+# Licence GPL v3
+
+###   xyValues   ###
+
+if (!isGeneric("xyValues")) {
+	setGeneric("xyValues", function(x, xyCoords)
+		standardGeneric("xyValues"))
+}	
+	
+setMethod("xyValues", signature(x='RasterLayer', xyCoords='matrix'), 
+	function(x, xyCoords) { 
+		if (dim(xyCoords)[2] != 2) {
+			stop('xyCoords has wrong dimensions; there should be 2 columns only' )
+		}
+		cells <- cellFromXY(x, xyCoords)
+		return(.rasterReadCells(x, cells))
+	}	
+)	
+
+
+setMethod("xyValues", signature(x='RasterStack', xyCoords='matrix'), 
+	function(x, xyCoords) { 
+		if (dim(xyCoords)[2] != 2) {
+			stop('xyCoords has wrong dimensions; there should be 2 columns only' )
+		}
+		cells <- cellFromXY(x, xyCoords)
+		return(.stackReadCells(x, cells))
+	}	
+)
+
+
+
+setMethod("xyValues", signature(x='RasterLayer', xyCoords='SpatialPoints'), 
+	function(x, xyCoords) { 
+		xyCoords <- coordinates(xyCoords)
+		cells <- cellFromXY(x, xyCoords)
+		return(.rasterReadCells(x, cells))
+	}	
+)
+
+
+setMethod("xyValues", signature(x='RasterStack', xyCoords='SpatialPoints'), 
+	function(x, xyCoords) { 
+		xyCoords <- coordinates(xyCoords)
+		cells <- cellFromXY(x, xyCoords)
+		return(.stackReadCells(x, cells))
+	}	
+)
+

Modified: pkg/raster/man/Logic-methods.Rd
===================================================================
--- pkg/raster/man/Logic-methods.Rd	2009-03-03 06:54:10 UTC (rev 304)
+++ pkg/raster/man/Logic-methods.Rd	2009-03-03 10:07:38 UTC (rev 305)
@@ -11,16 +11,31 @@
 
 \title{ Methods for logical functions for RasterLayers' }
 \description{
-The following boolean operators are available: '&', '|', and '!'
-With r being a RasterLayer, and the result a RasterLayer with logical values:
-	r <- r < 3 | r < 6
-	r <- !r
-These are also available :
-	is.na(r) 
-	is.nan(r)
-	is.finite(r)
-	is.infinite(object)
+The following logical (boolean) operators are available for computations with RasterLayer objects: \code{"&", "|", and "!"}
+These functions are also available with a RasterLayer argument: \code{is.na}, \code{is.nan}, \code{is.finite}, \code{is.infinite}
 }
 
+\value{
+A RasterLayer object with logical (\code{TRUE/FALSE} values)
+}
+
+
+\section{Note}{
+ If the values of the output RasterLayer cannot be held in memory, they will be saved to a temporary file. 
+ If you want to set the filename (and perhaps filetype and datatype), use \code{\link[raster]{calc-methods}} instead.
+}
+
+\seealso{ \code{\link[raster]{Math-methods}}, \code{\link[raster]{overlay-methods}}, \code{\link[raster]{calc-methods}} }
+
+
+\author{Robert J. Hijmans}
+
+\examples{
+r <- raster(ncols=10, nrows=10)
+r[] <- runif(ncell(r)) * 10
+r <- r < 3 | r < 6
+r <- !r
+}
+
 \keyword{methods}
 \keyword{math}

Added: pkg/raster/man/RasterLayer-class.Rd
===================================================================
--- pkg/raster/man/RasterLayer-class.Rd	                        (rev 0)
+++ pkg/raster/man/RasterLayer-class.Rd	2009-03-03 10:07:38 UTC (rev 305)
@@ -0,0 +1,123 @@
+\name{Raster-class}
+
+\docType{class}
+
+\alias{BasicRaster-class}
+\alias{Raster-class}
+\alias{RasterLayer-class}
+\alias{RasterStack-class}
+
+\alias{show,BasicRaster-method}
+\alias{show,RasterLayer-method}
+
+\title{ Raster* classes}
+
+
+\description{ \code{RasterLayer} and \code{RasterStack} (Raster* in short) are classes for handling spatial raster (grid) data.
+
+ RasterLayer represents a single layer raster.  RasterStack represents a collection of RasterLayers with the same extent and resolution; for example a multi-band remote sensing image. 
+ 
+A RasterStack is that it typically points to several seperate data files on disk, but it could also point to different bands from a single file (or not not point to any file at all)
+ 
+Apart from with the normal new(" ") method, objects can be created with the following functions (among others)
+\code{raster(), RasterFromFile(), stack(),  StackFromFile(), StackFromRasters(), StackFromFiles()}
+ 
+ RasterLayer and RasterStack objects can also be created from SpatialPixels* and SpatialGrid* objects from the sp package using \code{as}
+ or the explicit functions \code{asRasterLayer()} and \code{asRasterStack()}
+ Vice versa, Raster* objects can be coerced into a sp type oject with \code{asSpGrid()}. 
+ 
+ generic methods implemented for these classes include: 
+ \code{summary}, \code{show}, \code{dim}, \code{hist},
+ \code{plot} (with a single object as argument, and in the case of hist and plot, with additional ... parameters)
+ \code{[} is implemented for RasterLayer. It is equivalent to setValues() 
+ 
+ These classes inherit from the \code{Raster}, which is a virtual class (objects cannot be created from it). However, many of the generic methods
+ in this package are implemented for the Raster class so that they can be used with the other three classes.
+
+ In case you really want a Raster object, rather than one of its decendants, to work with you can easily create your own class that is the same (but not virtual) with a command like this:
+\code{setClass ('BasicRaster', contains = 'Raster')}
+ Raster includes a slot with an object of the \code{BoundingBox} class )
+ RasterLayer includes the classes \code{RasterFile} and \code{SingleLayerData}, whereas RasterStack contains \code{RasterFile} and \code{MultipleLayerData}
+ These classes are not further described here because users should not need to directly access these slots. 
+ The 'setter' functions such as setValues should be used instead. Using such 'set' functions
+ is much safe because a change in one slot should often affect the values in other slots. 
+ }
+
+
+\section{Objects from the Class}{
+Objects can be created by calls of the form \code{new("RasterLayer", ...)}, or with the helper functions such as \code{raster}.
+}
+\section{Slots}{
+Slots for RasterLayer and RasterStack objects
+
+	\describe{
+    \item{\code{title}:}{Object of class \code{"character"} }
+    \item{\code{file}:}{Object of class \code{"RasterFile"} }
+    \item{\code{data}:}{Object of class \code{"SingleLayerData"} or \code{"MulitpleLayerData"}}
+    \item{\code{history}:}{Object of class \code{"vector"} }
+    \item{\code{bbox}:}{Object of class \code{"BoundingBox"} }
+    \item{\code{ncols}:}{Object of class \code{"integer"} }
+    \item{\code{nrows}:}{Object of class \code{"integer"} }
+    \item{\code{crs}:}{Object of class \code{"CRS"} }
+  }
+}
+\section{Extends}{
+Classes \code{RasterLayer} and \code{RasterStack} extend class \code{"\linkS4class{Raster}"}, directly.
+Classes \code{RasterLayer} and \code{RasterStack} extend class \code{"\linkS4class{BasicRaster}"}, by class "Raster", distance 2.
+}
+\section{Methods}{
+  \describe{
+    \item{!}{\code{signature(x = "RasterLayer")}: ... }
+    \item{[}{\code{signature(x = "RasterLayer")}: ... }
+    \item{[[}{\code{signature(x = "RasterLayer", i = "ANY", j = "ANY")}: ... }
+    \item{[[<-}{\code{signature(x = "RasterLayer", i = "ANY", j = "ANY")}: ... }
+    \item{[<-}{\code{signature(x = "RasterLayer")}: ... }
+    \item{aggregate}{\code{signature(x = "RasterLayer")}: ... }
+    \item{calc}{\code{signature(x = "RasterLayer", fun = "function")}: ... }
+    \item{cellValues}{\code{signature(object = "RasterLayer", cells = "vector")}: ... }
+    \item{is.finite}{\code{signature(x = "RasterLayer")}: ... }
+    \item{is.infinite}{\code{signature(x = "RasterLayer")}: ... }
+    \item{is.na}{\code{signature(x = "RasterLayer")}: ... }
+    \item{is.nan}{\code{signature(x = "RasterLayer")}: ... }
+    \item{merge}{\code{signature(x = "RasterLayer", y = "RasterLayer")}: ... }
+    \item{overlay}{\code{signature(x = "RasterLayer", y = "RasterLayer")}: ... }
+    \item{plot}{\code{signature(x = "RasterLayer", y = "RasterLayer")}: ... }
+    \item{readAll}{\code{signature(object = "RasterLayer")}: ... }
+    \item{readBlock}{\code{signature(object = "RasterLayer")}: ... }
+    \item{readPartOfRow}{\code{signature(object = "RasterLayer")}: ... }
+    \item{readRow}{\code{signature(object = "RasterLayer")}: ... }
+    \item{readRows}{\code{signature(object = "RasterLayer")}: ... }
+    \item{setValues}{\code{signature(object = "RasterLayer")}: ... }
+    \item{show}{\code{signature(object = "RasterLayer")}: ... }
+    \item{stack}{\code{signature(x = "RasterLayer")}: ... }
+    \item{summary}{\code{signature(object = "RasterLayer")}: ... }
+    \item{xyValues}{\code{signature(object = "RasterLayer", xyCoords = "matrix")}: ... }
+	
+	
+    \item{asRasterLayer}{\code{signature(object = "RasterStack")}: ... }
+    \item{calc}{\code{signature(x = "RasterStack", fun = "function")}: ... }
+    \item{calc}{\code{signature(x = "RasterStack", fun = "list")}: ... }
+    \item{cellValues}{\code{signature(object = "RasterStack", cells = "vector")}: ... }
+    \item{nlayers}{\code{signature(object = "RasterStack")}: ... }
+    \item{overlay}{\code{signature(x = "RasterStack", y = "missing")}: ... }
+    \item{readAll}{\code{signature(object = "RasterStack")}: ... }
+    \item{readPartOfRow}{\code{signature(object = "RasterStack")}: ... }
+    \item{readRow}{\code{signature(object = "RasterStack")}: ... }
+    \item{setValues}{\code{signature(object = "RasterStack")}: ... }
+    \item{show}{\code{signature(object = "RasterStack")}: ... }
+    \item{summary}{\code{signature(object = "RasterStack")}: ... }
+    \item{xyValues}{\code{signature(object = "RasterStack", xyCoords = "matrix")}: ... }
+    \item{xyValues}{\code{signature(object = "RasterStack", xyCoords = "SpatialPoints")}: ... }
+	
+	 }
+}
+
+\author{ Robert J. Hijmans }
+
+
+\examples{
+showClass("RasterLayer")
+}
+
+\keyword{classes}
+\keyword{spatial}

Added: pkg/raster/man/Replace-methods.Rd
===================================================================
--- pkg/raster/man/Replace-methods.Rd	                        (rev 0)
+++ pkg/raster/man/Replace-methods.Rd	2009-03-03 10:07:38 UTC (rev 305)
@@ -0,0 +1,37 @@
+\name{replaceMethods}
+\docType{methods}
+
+\alias{[,RasterLayer-method}
+\alias{[<-,RasterLayer-method}
+\alias{[[,RasterLayer,ANY,ANY-method}
+\alias{[[<-,RasterLayer,ANY,ANY-method}
+\alias{[,RasterStack-method}
+
+\title{ Replace methods }
+
+\description{
+  \code{[} is sometimes equivalent to setValues() 
+}
+
+\section{Methods}{
+\describe{
+
+
+}}
+
+\examples{
+r <- raster(ncol=10, nrow=5)
+r[] <- 1:ncell(r) * 2
+r[1]
+r[[1,1]]
+r[50]
+r[[5,10]]
+
+r[1:10]
+r[3:8] <- NA
+r[1:10]
+
+}
+
+\keyword{methods}
+\keyword{spatial}

Deleted: pkg/raster/man/cell.values.Rd
===================================================================
--- pkg/raster/man/cell.values.Rd	2009-03-03 06:54:10 UTC (rev 304)
+++ pkg/raster/man/cell.values.Rd	2009-03-03 10:07:38 UTC (rev 305)
@@ -1,57 +0,0 @@
-\name{Cell values}
-\alias{cellValues}
-\alias{xyValues}
-\alias{xyValues,RasterLayer,SpatialPoints-method}
-\alias{xyValues,RasterStack,SpatialPoints-method}
-\alias{xyValues,RasterLayer,matrix-method}
-\alias{xyValues,RasterStack,matrix-method}
-\alias{cellValues,RasterLayer,vector-method}
-\alias{cellValues,RasterStack,vector-method}
-  
-  
-\title{Get raster properties}
-\description{
-  cellValues and xyValues return a vector of values for specified cells or xy coordiates
-  minValue and maxValue return the extreme data values for a RasterLayer (or layer in a RasterStack)
-}
-
-\usage{
-cellValues(object, cells)
-xyValues(object, xyCoords)
-}
-
-\arguments{
-  \item{object}{RasterLayer or RasterStack object}
-  \item{cells}{vector of cell numbers}
-  \item{xyCoords}{matrix of x and y coordinates (i.e. 2 columns)}
-}
-  
-
-\note{
-nothing  
-}
-
-\value{
-raster cell value(s)
-}
-
-\author{Robert J. Hijmans }
-\examples{
-#using a new default raster (1 degree global)
-r <- raster()
-r <- setValues(r, 1:ncell(r))
-cellValues(r, c(1, 10, 100))
-xy <- cbind(1:20, 20:1)
-xyValues(r, xy)
-
-r <- rasterFromFile(system.file("external/test.ag", package="sp"))
-# read values for cells
-  cells <- c(1, 1900, 5000)
-  cellValues(r, cells)
-
-# read values for (x, y) coordinates
-  xy <- xyFromCell(r, cells)
-  xyValues(r, xy)
-
-}
-\keyword{spatial}

Added: pkg/raster/man/cellValues-methods.Rd
===================================================================
--- pkg/raster/man/cellValues-methods.Rd	                        (rev 0)
+++ pkg/raster/man/cellValues-methods.Rd	2009-03-03 10:07:38 UTC (rev 305)
@@ -0,0 +1,46 @@
+\name{cellValues}
+\docType{methods}
+
+\alias{cellValues}
+\alias{cellValues,RasterLayer,vector-method}
+\alias{cellValues,RasterStack,vector-method}
+
+\title{ values for cells }
+\description{
+ These methods return values of a RasterLayer or RasterStack for specified cells )
+}
+\section{Methods}{
+\describe{
+\code{cellValues(x, cells)}
+
+\item{code{x}}{RasterLayer or RasterStack object}
+\item{code{cells}}{vector of cell numbers, cell numbers should be between 1 and ncells(x)}
+
+}}
+
+
+\value{
+a vector of cell values for a RasterLayer or or a matrix of values for a RasterStack
+}
+
+\seealso{ \code{\link[raster]{xyValues}}, \code{\link[raster]{readRow}}, \code{\link[raster]{readAll}} }
+
+
+\author{Robert J. Hijmans }
+
+
+\examples{
+#using a new default raster (1 degree global)
+r <- raster()
+r <- setValues(r, 1:ncell(r))
+cellValues(r, c(1, 10, 100))
+
+r <- rasterFromFile(system.file("external/test.ag", package="sp"))
+cells <- c(1, 1900, 5000)
+cellValues(r, cells)
+
+}
+
+
+\keyword{methods}
+\keyword{spatial}

Modified: pkg/raster/man/cellsFromBbox.Rd
===================================================================
--- pkg/raster/man/cellsFromBbox.Rd	2009-03-03 06:54:10 UTC (rev 304)
+++ pkg/raster/man/cellsFromBbox.Rd	2009-03-03 10:07:38 UTC (rev 305)
@@ -1,4 +1,4 @@
-\name{box}
+\name{fromBbox}
 \alias{cellsFromBbox}
 \alias{polygonFromBbox}
 
@@ -22,12 +22,12 @@
 }
 
 \value{
-in most cases a BoundingBox object
+a vector of cell numbers of a SpatialPolygons object
 }  
   
 \author{Robert J. Hijmans}
 
-\seealso{ \code{\link[raster]{newBbox}} }
+\seealso{ \code{\link[raster]{newBbox}}, \code{\link[sp]{SpatialPolygons}} }
 
 \examples{
 r <- raster()

Modified: pkg/raster/man/classes.Rd
===================================================================
--- pkg/raster/man/classes.Rd	2009-03-03 06:54:10 UTC (rev 304)
+++ pkg/raster/man/classes.Rd	2009-03-03 10:07:38 UTC (rev 305)
@@ -1,53 +1,16 @@
 \name{classes}
 \docType{class}
 
-
-\alias{BasicRaster-class}
-\alias{Raster-class}
-\alias{RasterLayer-class}
-\alias{RasterStack-class}
-\alias{show,BasicRaster-method}
-\alias{show,RasterLayer-method}
 \alias{show,RasterStack-method}
-\alias{show,RasterLayerSummary-method}
 \alias{hist,Raster-method}
 \alias{dim,BasicRaster-method}
 \alias{summary,RasterLayer-method}
+\alias{show,RasterLayerSummary-method}
 \alias{summary,RasterStack-method}
-\alias{[,RasterLayer-method}
-\alias{[<-,RasterLayer-method}
-\alias{[,RasterStack-method}
-\alias{[[,RasterLayer,ANY,ANY-method}
-\alias{[[<-,RasterLayer,ANY,ANY-method}
 
-\title{Classes for handling raster data }
-\description{ \code{RasterLayer}, \code{RasterStack} (Raster* in short) are all classes for handling spatial raster (grid) data.
-
- RasterLayer represents a single layer raster.
- RasterStack represents a collection of RasterLayers with the same extent and resolution; for example a multi-band remote sensing image. 
- 
- The difference between a RasterStack is that it typically points to several seperate data files on disk, but it could also point to different bands from a single file (or not not point to any file at all)
- 
- Apart from with the normal new(" ") method, objects can be created with the following functions (among others)
- raster(), RasterFromFile(), StackFromFile(), StackFromRasters(), StackFromFiles()
- 
- RasterLayer and RasterStack objects can also be created from SpatialPixels* and SpatialGrid* objects from the sp package: asRasterLayer(), asRasterStack()
- Vice versa, Raster* objects can be coerced into a sp type oject with asSpGrid(). You can also use SetAs() 
- 
- generic methods implemented for these classes are: 
- \code{summary}, \code{show}, \code{dim}, \code{hist}, \code{plot} (with a single object as argument, and in the case of hist and plot, with additional ... parameters)
- \code{[} is implemented for RasterLayer. It is equivalent to setValues() 
- 
- These classes inherit from the \code{Raster}, which is a virtual class (objects cannot be created from it). However, many of the generic methods
- in this package are implemented for the Raster class so that they can be used with the other three classes.
-
- In case you really want a Raster object, rather than one of its decendants, to work with you can easily create your own class that is the same (but not virtual) with a command like this:
-\code{setClass ('BasicRaster', contains = 'Raster')}
- Raster includes the \code{BoundingBox} class that is not virtual (e.g. see newBbox() )
- RasterLayer includes the classes \code{RasterFile} and \code{SingleLayerData}, whereas RasterStack contains \code{RasterFile} and \code{MultipleLayerData}
- These classes are not further described here, because users should not need to directly access the slots in these classes. There are functions for that. Using these functions
- is much safer because a change in one slot should often affect the values in other slots. The 'setter' functions such as setValues take care of that. 
-
+\title{Replace methods }
+\description{ 
+   to be moved ....
  }
 
 

Modified: pkg/raster/man/coerce.Rd
===================================================================
--- pkg/raster/man/coerce.Rd	2009-03-03 06:54:10 UTC (rev 304)
+++ pkg/raster/man/coerce.Rd	2009-03-03 10:07:38 UTC (rev 305)
@@ -25,9 +25,9 @@
  if \code{type} is 'pixel' a SpatialPixel* object is returned. If the RasterLayer object has data a SpatialPixelDataFrame will be returned.
  if \code{type} is 'grid' a SpatialGrid* object is returned. If the RasterLayer object has data a SpatialGridDataFrame will be returned.
  
- In most cases you can also coerce objects using setAs, except that you cannot change the default 'index' (variable) and the first variable (column of the data frame of a Spatial* object) is used.
+ In most cases you can also coerce objects using \code{as}, except that you cannot change the default 'index' (variable) and the first variable (column of the data frame of a Spatial* object) is used.
  
- e.g.: as(aSpatialPixelsDataFrame, "RasterStack") or as(aRasterLayer, "SpatialGridDataFrame")
+ e.g.: \code{as(aSpatialPixelsDataFrame, "RasterStack")} or \code{as(aRasterLayer, "SpatialGridDataFrame")}
 }
 
 \value{
@@ -35,7 +35,7 @@
 }
 \author{ Robert J. Hijmans}
 
-\seealso{ \code{\link[raster]{classes}}, \code{\link[sp]{SpatialGridDataFrame-class}}, \code{\link[methods]{as}}}
+\seealso{ \code{\link[raster]{RasterLayer-class}}, \code{\link[sp]{SpatialGridDataFrame-class}}, \code{\link[methods]{as}}}
 
 \examples{ 
 r1 <- raster(ncols=90, nrows=45)

Modified: pkg/raster/man/overlay-methods.Rd
===================================================================
--- pkg/raster/man/overlay-methods.Rd	2009-03-03 06:54:10 UTC (rev 304)
+++ pkg/raster/man/overlay-methods.Rd	2009-03-03 10:07:38 UTC (rev 305)
@@ -1,9 +1,17 @@
 \name{overlay}
 \docType{methods}
+
 \alias{overlay}
 \alias{overlay,RasterLayer,RasterLayer-method}
-\title{ method for function overlay in the raster package}
+\alias{overlay,RasterLayer,missing-method}
+\alias{overlay,list,missing-method}
+
+\alias{overlay,RasterStack,missing-method}
+
+\title{Overlay RasterLayers}
+
 \description{
+
 Calculate values for a new RasterLayer object, based on two or more existing and RasterLayers of the same extent and resolution. 
 overlay is a generic functon used in the sp and raster packages. This help file describes its use in the raster package. 
 
@@ -11,7 +19,6 @@
 For example, if you merge two RasterLayers you could use multiply: \code{fun=function(x,y){return(x*y)}} percentage: \code{fun=function(x,y){return(100 * x / y)}}. 
 The default function \code{sum} always works because its first argument is \code{...}
 
-In stead of the overlay function you can also use normal artimic functions (*, /, +, -) with RasterLayer objects (see examples) 
 }
 
 \section{Methods}{
@@ -27,9 +34,12 @@
 }
 }
 
+\details{
+In stead of the overlay function you can also use normal artimic functions such as *, /, +, - with RasterLayer objects (see examples), but then you cannot specifiy an output filename, filetype or datatype. 
+}
 
 \value{
-a new RasterLayer object (if a filename is provided, a file on disk)
+a new RasterLayer object (and in some cases, if a filename is provided or the output values cannot be stored in memory, the side effect of a file on disk)
 }
 
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/raster -r 305


More information about the Raster-commits mailing list