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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Mar 7 09:24:50 CET 2009


Author: rhijmans
Date: 2009-03-07 09:24:49 +0100 (Sat, 07 Mar 2009)
New Revision: 319

Added:
   pkg/raster/R/bilinearValue.R
   pkg/raster/man/aggregate.Rd
   pkg/raster/man/cellValues.Rd
   pkg/raster/man/cover.Rd
   pkg/raster/man/merge.Rd
   pkg/raster/man/overlay.Rd
   pkg/raster/man/replacement.Rd
Removed:
   pkg/raster/man/Replace-methods.Rd
   pkg/raster/man/aggregate-methods.Rd
   pkg/raster/man/cellValues-methods.Rd
   pkg/raster/man/cover-methods.Rd
   pkg/raster/man/merge-methods.Rd
   pkg/raster/man/overlay-methods.Rd
Modified:
   pkg/raster/DESCRIPTION
   pkg/raster/R/crop.R
   pkg/raster/R/resample.R
   pkg/raster/R/xyCell.R
   pkg/raster/man/disaggregate.Rd
   pkg/raster/man/pointdistance.Rd
   pkg/raster/man/resample.Rd
   pkg/raster/man/xyValues-methods.Rd
Log:


Modified: pkg/raster/DESCRIPTION
===================================================================
--- pkg/raster/DESCRIPTION	2009-03-06 12:19:50 UTC (rev 318)
+++ pkg/raster/DESCRIPTION	2009-03-07 08:24:49 UTC (rev 319)
@@ -1,11 +1,11 @@
 Package: raster
 Type: Package
 Title: Raster data handling for geographic data analysis and modeling
-Version: 0.8.9-3
-Date: 6-March-2009
+Version: 0.8.9-4
+Date: 7-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> 
-Description: Package for reading and manipulating (geographic, spatial) raster (grid) data
+Description: Package for reading, writing, and manipulating (geographic, spatial) raster (grid) data
 License: GPL3
 URL: http://raster.r-forge.r-project.org/
\ No newline at end of file

Added: pkg/raster/R/bilinearValue.R
===================================================================
--- pkg/raster/R/bilinearValue.R	                        (rev 0)
+++ pkg/raster/R/bilinearValue.R	2009-03-07 08:24:49 UTC (rev 319)
@@ -0,0 +1,58 @@
+
+.fourCellsFromXY <- function(raster, xy) {
+	cells <- cellFromXY(raster, xy)
+	row <- rowFromCell(raster, cells)
+	col <- colFromCell(raster, cells)
+	cellsXY <- xyFromCell(raster, cells)
+
+	pos <- matrix(-1, ncol=ncol(xy), nrow=nrow(xy))
+	pos[xy[,1] > cellsXY[,1]] <- 1
+	pos[xy[,2] < cellsXY[,2]] <- 1
+	
+	four <- matrix(ncol=4, nrow=nrow(xy))
+	four[,1] <- cells
+	four[,2] <- cellFromRowCol(raster, row + pos[,2], col)
+	four[,3] <- cellFromRowCol(raster, row + pos[,2], col + pos[,1])
+	four[,4] <- cellFromRowCol(raster, row, col + pos[,1])
+		
+	four[is.na(four)] <- rep(four[,1], 4)[is.na(four)]
+	return(four)
+}
+
+
+.bilinear <- function(x,y, x1,x2,y1,y2, q11,q12,q21,q22) {
+	div <- (x2-x1)*(y2-y1)
+	if (all(div>0)) {
+		return( (q11/div)*(x2-x)*(y2-y) + (q21/div)*(x-x1)*(y2-y) + (q12/div)*(x2-x)*(y-y1) + (q22/div)*(x-x1)*(y-y1) )
+	} else {
+		bil <- vector(length=length(div))
+		bil[div>0] <- (q11/div)*(x2-x)*(y2-y) + (q21/div)*(x-x1)*(y2-y) + (q12/div)*(x2-x)*(y-y1) + (q22/div)*(x-x1)*(y-y1) 
+		bil[(x1==x2 && y1==y2)] <- q11
+		div <- y2-y1
+		bil[(x1==x2 && y1!=y2)] <- (q11/div)*(y2-y) + (q12/div)*(y-y1)
+		div <- x2-x1
+		bil[(x1!=x2 && y1==y2)] <- (q11/div)*(x2-x) + (q21/div)*(x-x1) 
+	}
+	return(bil)
+}
+
+
+if (!isGeneric("bilinearValue")) {
+	setGeneric("bilinearValue", function(raster, xyCoords)
+		standardGeneric("bilinearValue"))
+}	
+
+setMethod("bilinearValue", signature(raster='RasterLayer', xyCoords='matrix'), 
+function(raster, xyCoords) {
+	four <- .fourCellsFromXY(raster, xyCoords)
+	xy4 <- matrix(xyFromCell(raster, as.vector(four)), ncol=8)
+	x1 <- apply(xy4[,1:4], 1, min)
+	x2 <- apply(xy4[,1:4], 1, max)
+	y1 <- apply(xy4[,5:8], 1, min)
+	y2 <- apply(xy4[,5:8], 1, max)
+	xy4 <- cbind(c(x1, x1, x2, x2), c(y1, y2, y1, y2))
+	cells <- cellFromXY(raster, xy4)
+	v <- matrix(cellValues(raster, cells), ncol=4)
+	return( .bilinear(xyCoords[,1], xyCoords[,2], x1, x2, y1, y2, v[,1], v[,2], v[,3], v[,4]) )
+}
+)

Modified: pkg/raster/R/crop.R
===================================================================
--- pkg/raster/R/crop.R	2009-03-06 12:19:50 UTC (rev 318)
+++ pkg/raster/R/crop.R	2009-03-07 08:24:49 UTC (rev 319)
@@ -10,7 +10,7 @@
 crop <- function(raster, bndbox, filename="", overwrite=FALSE, filetype='raster', track=-1) {
 
 # we could also allow the raster to expand but for now let's not and first make a separate expand function
-	bb <- intersectBbox(c(raster, bndbox))
+	bb <- intersectBbox(raster, bndbox)
 	bb <- alignBbox(bb, raster)
 	outraster <- setRaster(raster, filename)
 	outraster <- setExtent(outraster, bb, keepres=T)

Modified: pkg/raster/R/resample.R
===================================================================
--- pkg/raster/R/resample.R	2009-03-06 12:19:50 UTC (rev 318)
+++ pkg/raster/R/resample.R	2009-03-07 08:24:49 UTC (rev 319)
@@ -4,22 +4,47 @@
 # Version 0.8
 # Licence GPL v3
 
-resample <- function(from, to, method="nngb", overwrite=FALSE) {
-# do the bounding boxes overlap at all? 
-# get .innerbox first?
+
+
+resample <- function(from, to, method="ngb", filename=NULL, filetype='raster', datatype='FLT4S', overwrite=FALSE, track=-1)  {
+	if (!method %in% c('bilinear', 'ngb')) { stop('invalid method') 	}
+		
+	bb <- intersectBbox(from, to)
+	validObject(bb)
+	if (is.null(filename)){filename <- ""}
+	to <- setRaster(to, filename)
+	to <- setDatatype(to, datatype)
+	
+	if (!.CanProcessInMemory(to, 1) && filename(to) == '') {
+		filename <- tempfile()
+		to <- setFilename(to, filename )
+		if (options('verbose')[[1]]) { cat('writing raster to:', filename(to))	}
+	}
+	if (filename(to) == "") { inMemory <- TRUE} else { inMemory <- FALSE }
+
+	v <- vector(length=0)
 	rowCells <- 1:ncol(to)
-	inMemory <- filename(to) == ""
-	v <- vector(length=0)
+	starttime <- proc.time()
 	for (r in 1:nrow(to)) {
 		cells <- rowCells + (r-1) * ncol(to)
 		xy <- xyFromCell(to, cells)
-		vals <- xyValues(from, xy)
+		if (method=='ngb') {
+			vals <- xyValues(from, xy)
+		} else {
+			vals <- bilinearValue(from, xy)
+		}
 		if (inMemory) {
 			v <- c(v, vals)
 		} else {
 			to <- setValues(to, vals, r)
-			to <- writeRaster(to, overwrite=overwrite)
+			to <- writeRaster(to, overwrite=overwrite, filetype=filetype)
 		}
+		if (r %in% track) {
+			elapsed <- (proc.time() - starttime)[3]
+			tpr <- elapsed /r
+			ttg <- round(tpr/60 * (nrow(raster) - r), digits=1)
+			cat('row', r, '-', ttg, 'minutes to go\n')
+		}
 	}
 	if (inMemory) {
 		to <- setValues(to, v) 
@@ -27,5 +52,3 @@
 	return(to)
 }
 
-
-

Modified: pkg/raster/R/xyCell.R
===================================================================
--- pkg/raster/R/xyCell.R	2009-03-06 12:19:50 UTC (rev 318)
+++ pkg/raster/R/xyCell.R	2009-03-07 08:24:49 UTC (rev 319)
@@ -34,18 +34,13 @@
 		x <- xy[,1]
 		y <- xy[,2] 
 	}
-	cell <- vector(mode = "integer", length = length(x))
-	cell[] <- NA
-	for (i in seq(length(x))) {
-		colnr <- colFromX(object, x[i]) - 1
-		rownr <- rowFromY(object, y[i]) - 1
-		if ((!is.na(colnr)) & (!is.na(rownr))) {
-			cell[i] <- rownr * ncol(object) + colnr + 1
-		}
-	}
+	rownr <- rowFromY(object, y) - 1
+	colnr <- colFromX(object, x)
+	cell <- rownr * ncol(object) + colnr
 	return(cell)
 }
 
+
 colFromX <- function ( object, x )	{
 	if (.isSPgrid(object)) { object <- asRasterLayer(object, FALSE) }
 	if (class(x) == 'SpatialPoints' | class(x) == 'SpatialPointsDataFrame') {	x <- x at points[,1] }

Deleted: pkg/raster/man/Replace-methods.Rd
===================================================================
--- pkg/raster/man/Replace-methods.Rd	2009-03-06 12:19:50 UTC (rev 318)
+++ pkg/raster/man/Replace-methods.Rd	2009-03-07 08:24:49 UTC (rev 319)
@@ -1,43 +0,0 @@
-\name{replaceMethods}
-\docType{methods}
-
-\alias{[,RasterLayer-method}
-\alias{[,RasterLayer,ANY,ANY-method}
-\alias{[,RasterLayer,ANY,missing-method}
-
-\alias{[[,RasterLayer,ANY,ANY-method}
-
-\alias{[<-,RasterLayer-method}
-\alias{[<-,RasterLayer,ANY,missing-method}
-
-\title{ Replace methods }
-
-\description{
-  \code{[} is sometimes equivalent to setValues() 
-}
-
-\section{Methods}{
-\describe{
-  if r is a RasterLayer, r[] is valid with a single index (cell number)
-  e.g.: r[1], r[6:15]
-  r[[]] is valid with two indices
-  e.g.: r[[1,1]], r[[1,]]
-
-}}
-
-\examples{
-r <- raster(ncol=10, nrow=5)
-r[] <- 1:ncell(r) * 2
-r[1]
-
-r[1:10]
-r[3:8] <- NA
-r[1:10]
-
-#r[[,1]]
-#r[[1,]]
-
-}
-
-\keyword{methods}
-\keyword{spatial}

Deleted: pkg/raster/man/aggregate-methods.Rd
===================================================================
--- pkg/raster/man/aggregate-methods.Rd	2009-03-06 12:19:50 UTC (rev 318)
+++ pkg/raster/man/aggregate-methods.Rd	2009-03-07 08:24:49 UTC (rev 319)
@@ -1,81 +0,0 @@
-\name{aggregate}
-
-\docType{methods}
-
-\alias{aggregate}
-\alias{aggregate,RasterLayer-method}
-
-\title{Aggregate}
-
-\description{
-Aggregate a RasterLayer to create a new raster with a lower resolution (larger cells). Aggregation groups rectangular areas of RasterLayer cells to create a new RasterLayer with larger cells. 
-A new value is computed for the resulting cells according to a user specified function (default value = \code{mean}). 
-}
-
-\usage{
-aggregate(x, ...) 
-}
-
-
-\arguments{
-  \item{x}{A RasterLayer object}
-  \item{...}{Additional arguments. See below, under Methods}  
-}
-
-\section{Methods}{
-\describe{
-A full call to the aggregate method is:
-
-\code{aggregate(x, fact=2, fun=mean, expand=TRUE, na.rm=TRUE, filename=NULL, filetype='raster', datatype='FLT4S', overwrite=FALSE, track=-1) }
- 
-  \item{\code{x}}{a RasterLayer object}
-  \item{\code{fun}}{function used to aggregate values}
-  \item{\code{fact}}{integer. Aggregation factor expressed as number of cells in each direction (horizontally and vertically). Or two integers (horizontal and vertial aggregation fcator). See details}
-  \item{\code{expand}}{logical. If \code{TRUE} the output RasterLayer will get larger if a division of the number of columns or rows with \code{factor} does not return an integer}
-  \item{\code{na.rm}}{logical. If \code{TRUE}, remove NA cells from calculations}
-  \item{\code{filename}}{character. output filename}
-  \item{\code{overwrite}}{logical. If \code{TRUE}, "filename" will be overwritten if it exists}
-  \item{\code{filetype}}{character. output file type. Either 'raster', 'ascii' or a supported GDAL 'driver' name see \code{\link[raster]{rasterFormats}}}
-  \item{\code{datatype}}{character. output data type; see \code{\link[raster]{setDatatype}}}
-  \item{\code{track}}{vector of row numbers for which the function will report that they have been processed}   
-}
-}
-
-\details{
- Aggregation will result in a RasterLayer with \code{fact*fact} fewer cells; sometimes adjusted according to the values of \code{expand}.
- For example, \code{fact=2} will result in a new RasterLayer with \code{2*2=4} times fewer cells. 
- If two numbers are supplied, e.g., \code{fact=c(2,3)}, the first will be used for aggregating in the horizontal direction, 
- and the second for aggregating in the vertical direction, and the new RasterLayer will have \code{2*3=6} times fewer cells.  
- 
- If the input RasterLayer has 100 columns, and \code{fact=12}, the output RasterLayer will have either 8 columns (\code{expand=FALSE}) or 
- 9 columns (\code{expand=TRUE}). The maximum x coordinate of the output RasterLayer will, of course, also be affected.
- 
- Aggregation starts at the upper-left end of a raster.
- 
- The function \code{fun} should take multiple numbers, and return a single number. For example \code{mean}, \code{min} or \code{max}. 
- 
- If no filename is specified, and the resulting RasterLayer is too large to hold in memory, it is saved to a temporary file.  
- 
-}
-
-\value{
-A new RasterLayer object, and in some cases the side effect of a new file on disk.
-}
-
-
-\seealso{ \code{\link[raster]{disaggregate}} }
-
-\author{Robert J. Hijmans and Jacob van Etten}
-
-\examples{
-r <- raster()
-# a new aggregated raster, no values
-ra <- aggregate(r, fact=10)
-r <- setValues(r, runif(ncell(r)))
-ra <- aggregate(r, fact=10, fun=max)
-# a new aggregated raster, max of the values
-}
-
-\keyword{methods}
-\keyword{spatial}
-

Added: pkg/raster/man/aggregate.Rd
===================================================================
--- pkg/raster/man/aggregate.Rd	                        (rev 0)
+++ pkg/raster/man/aggregate.Rd	2009-03-07 08:24:49 UTC (rev 319)
@@ -0,0 +1,79 @@
+\name{aggregate}
+
+\docType{methods}
+
+\alias{aggregate}
+\alias{aggregate,RasterLayer-method}
+
+\title{Aggregate}
+
+\description{
+Aggregate a RasterLayer to create a new raster with a lower resolution (larger cells). Aggregation groups rectangular areas of RasterLayer cells to create a new RasterLayer with larger cells. 
+A new value is computed for the resulting cells according to a user specified function (default value = \code{mean}). 
+}
+
+\usage{
+aggregate(x, ...) 
+}
+
+
+\arguments{
+  \item{x}{A RasterLayer object}
+  \item{...}{Additional arguments. See below, under Methods}  
+}
+
+\section{Methods}{
+\describe{
+A full call to the aggregate method is:
+
+\code{aggregate(x, fact=2, fun=mean, expand=TRUE, na.rm=TRUE, filename=NULL, filetype='raster', datatype='FLT4S', overwrite=FALSE, track=-1) }
+ 
+  \item{\code{x}}{a RasterLayer object}
+  \item{\code{fun}}{function used to aggregate values}
+  \item{\code{fact}}{integer. Aggregation factor expressed as number of cells in each direction (horizontally and vertically). Or two integers (horizontal and vertial aggregation fcator). See details}
+  \item{\code{expand}}{logical. If \code{TRUE} the output RasterLayer will get larger if a division of the number of columns or rows with \code{factor} does not return an integer}
+  \item{\code{na.rm}}{logical. If \code{TRUE}, remove NA cells from calculations}
+  \item{\code{filename}}{character. output filename}
+  \item{\code{overwrite}}{logical. If \code{TRUE}, "filename" will be overwritten if it exists}
+  \item{\code{filetype}}{character. output file type. Either 'raster', 'ascii' or a supported GDAL 'driver' name see \code{\link[raster]{rasterFormats}}}
+  \item{\code{datatype}}{character. output data type; see \code{\link[raster]{setDatatype}}}
+  \item{\code{track}}{vector of row numbers for which the function will report that they have been processed}   
+}
+}
+
+\details{
+ Aggregation will result in a RasterLayer with \code{fact*fact} fewer cells; sometimes adjusted according to the values of \code{expand}.
+ For example, \code{fact=2} will result in a new RasterLayer with \code{2*2=4} times fewer cells. 
+ If two numbers are supplied, e.g., \code{fact=c(2,3)}, the first will be used for aggregating in the horizontal direction, 
+ and the second for aggregating in the vertical direction, and the new RasterLayer will have \code{2*3=6} times fewer cells.  
+ 
+ If the input RasterLayer has 100 columns, and \code{fact=12}, the output RasterLayer will have either 8 columns (\code{expand=FALSE}) or 
+ 9 columns (\code{expand=TRUE}). The maximum x coordinate of the output RasterLayer will, of course, also be affected.
+ 
+ Aggregation starts at the upper-left end of a raster.
+ 
+ The function \code{fun} should take multiple numbers, and return a single number. For example \code{mean}, \code{min} or \code{max}. 
+ 
+ If no filename is specified, and the resulting RasterLayer is too large to hold in memory, it is saved to a temporary file.  
+}
+
+\value{
+A new RasterLayer object, and in some cases the side effect of a new file on disk.
+}
+
+\seealso{ \code{\link[raster]{disaggregate}} }
+
+\author{Robert J. Hijmans and Jacob van Etten}
+
+\examples{
+r <- raster()
+# a new aggregated raster, no values
+ra <- aggregate(r, fact=10)
+r <- setValues(r, runif(ncell(r)))
+ra <- aggregate(r, fact=10, fun=max)
+# a new aggregated raster, max of the values
+}
+
+\keyword{methods}
+\keyword{spatial}
+

Deleted: pkg/raster/man/cellValues-methods.Rd
===================================================================
--- pkg/raster/man/cellValues-methods.Rd	2009-03-06 12:19:50 UTC (rev 318)
+++ pkg/raster/man/cellValues-methods.Rd	2009-03-07 08:24:49 UTC (rev 319)
@@ -1,46 +0,0 @@
-\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}

Added: pkg/raster/man/cellValues.Rd
===================================================================
--- pkg/raster/man/cellValues.Rd	                        (rev 0)
+++ pkg/raster/man/cellValues.Rd	2009-03-07 08:24:49 UTC (rev 319)
@@ -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}

Deleted: pkg/raster/man/cover-methods.Rd
===================================================================
--- pkg/raster/man/cover-methods.Rd	2009-03-06 12:19:50 UTC (rev 318)
+++ pkg/raster/man/cover-methods.Rd	2009-03-07 08:24:49 UTC (rev 319)
@@ -1,54 +0,0 @@
-\name{cover}
-\docType{methods}
-
-\alias{cover}
-\alias{cover,RasterLayer,RasterLayer-method}
-
-\title{ cover }
-\description{
- Replace \code{NA} values in the first RasterLayer with the values of the second RasterLayer
- 
- 
-}
-\section{Methods}{
-\describe{
-\code{cover(x, y, filename="", overwrite=TRUE) }
-
-  \item{\code{x}}{ a RasterLayer object }
-  \item{\code{y}}{ a RasterLayer object }
-  \item{\code{filename}}{ filename for the output raster. A valid filename must be provided when the data of the input rasters are on disk }
-  \item{\code{overwrite}}{logical. If \code{TRUE}, existing files will be overwritten}
-
-
-\item{x = "RasterLayer", y = "RasterLayer"}{ ~~describe this method here }
-}}
-
-\details{
-The function returns a RasterLayer with the values of the second RasterLayer, \code{y}, 
-where the values of the first RasterLayer, \code{x}, are NA and the values of the first RasterLayer elsewhere.
-
-If the input RasterLayer objects have all values in memory (e.g. after readAll(raster)), 
-the function will also return the new values in memory. If a filename is provided, the values will also be saved to that file. 
-
-If no filename is specified, and the resulting RasterLayer is too large to hold in memory, it is saved to a temporary file.  
-}
-
-\value{
-A new RasterLayer object, and in some cases the side effect of a new file on disk.
-}
-
-\author{Robert J. Hijmans}
-
-\examples{
-r1 <- raster(ncols=36, nrows=18)
-r1[] <- 1:ncell(r1)
-r2 <- setValues(r1, runif(ncell(r1)))
-r2 <- calc(r2, fun=function(x){ x[x<0.5] <- NA; return(x)} )
-#equivalent to: 
-#r2[r2<0.5] <- NA
-
-r3 <- cover(r2, r1)
-}	
-
-\keyword{methods}
-\keyword{spatial}

Added: pkg/raster/man/cover.Rd
===================================================================
--- pkg/raster/man/cover.Rd	                        (rev 0)
+++ pkg/raster/man/cover.Rd	2009-03-07 08:24:49 UTC (rev 319)
@@ -0,0 +1,54 @@
+\name{cover}
+\docType{methods}
+
+\alias{cover}
+\alias{cover,RasterLayer,RasterLayer-method}
+
+\title{ cover }
+\description{
+ Replace \code{NA} values in the first RasterLayer with the values of the second RasterLayer
+ 
+ 
+}
+\section{Methods}{
+\describe{
+\code{cover(x, y, filename="", overwrite=TRUE) }
+
+  \item{\code{x}}{ a RasterLayer object }
+  \item{\code{y}}{ a RasterLayer object }
+  \item{\code{filename}}{ filename for the output raster. A valid filename must be provided when the data of the input rasters are on disk }
+  \item{\code{overwrite}}{logical. If \code{TRUE}, existing files will be overwritten}
+
+
+\item{x = "RasterLayer", y = "RasterLayer"}{ ~~describe this method here }
+}}
+
+\details{
+The function returns a RasterLayer with the values of the second RasterLayer, \code{y}, 
+where the values of the first RasterLayer, \code{x}, are NA and the values of the first RasterLayer elsewhere.
+
+If the input RasterLayer objects have all values in memory (e.g. after readAll(raster)), 
+the function will also return the new values in memory. If a filename is provided, the values will also be saved to that file. 
+
+If no filename is specified, and the resulting RasterLayer is too large to hold in memory, it is saved to a temporary file.  
+}
+
+\value{
+A new RasterLayer object, and in some cases the side effect of a new file on disk.
+}
+
+\author{Robert J. Hijmans}
+
+\examples{
+r1 <- raster(ncols=36, nrows=18)
+r1[] <- 1:ncell(r1)
+r2 <- setValues(r1, runif(ncell(r1)))
+r2 <- calc(r2, fun=function(x){ x[x<0.5] <- NA; return(x)} )
+#equivalent to: 
+#r2[r2<0.5] <- NA
+
+r3 <- cover(r2, r1)
+}	
+
+\keyword{methods}
+\keyword{spatial}

Modified: pkg/raster/man/disaggregate.Rd
===================================================================
--- pkg/raster/man/disaggregate.Rd	2009-03-06 12:19:50 UTC (rev 318)
+++ pkg/raster/man/disaggregate.Rd	2009-03-07 08:24:49 UTC (rev 319)
@@ -31,6 +31,9 @@
 \value{
 A new RasterLayer object, and in some cases the side effect of a new file on disk.
 }
+
+\seealso{ \code{\link[raster]{aggregate}} }
+
 \author{Robert J. Hijmans}
 
 \examples{

Deleted: pkg/raster/man/merge-methods.Rd
===================================================================
--- pkg/raster/man/merge-methods.Rd	2009-03-06 12:19:50 UTC (rev 318)
+++ pkg/raster/man/merge-methods.Rd	2009-03-07 08:24:49 UTC (rev 319)
@@ -1,53 +0,0 @@
-\name{merge}
-
-\docType{methods}
-\alias{merge}
-\alias{merge,RasterLayer,RasterLayer-method}
-\title{ 
-Merge RasterLayers
-
-}
-
-\description{
-Merge RasterLayers to form a new RasterLayer with a larger spatial extent
-
-This is a method for the generic function in Package `base'
-
-}
-
-\section{Methods}{
-\describe{
-\code{merge(x, y, ..., tolerance=0.05, filename="", overwrite=FALSE) }
-
-\item{x,y}{"RasterLayer"}{
-  \item{...}{additional RasterLayer objects}
-  \item{tolerance}{difference permissable (relative to the cell resolution) for objects to be 'equal'. See ?all.equal}
-  \item{filename}{output filename for a new raster}
-  \item{overwrite}{if \code{TRUE}, the file will be overwritten if it exists}
-}} }
-
-\details{
-The RasterLayer objects must have the same origin and resolution. In areas where the RasterLayers overlap, the values of the RasterLayer that is first in the sequence will be retained. 
-}
-
-\value{
-A new RasterLayer object (in the R environment), and in some cases the side effect of a new file on disk.
-}
-\author{Robert J. Hijmans}
-
-\seealso{ \code{\link[raster]{crop}}, \code{\link[raster]{expand}}}
-
-\examples{
-r1 <- raster(xmx=-150, ymn=60, ncols=30, nrows=30)
-r1[] <- 1:ncell(r1)
-r2 <- raster(xmn=-100, xmx=-50, ymx=50, ymn=30)
-r2 <- setRes(r2, xres(r1), yres(r1))
-r2[] <- 1:ncell(r2)
-rm <- merge(r1, r2)
-}
-
-\keyword{methods}
-\keyword{spatial}
-
-
-

Added: pkg/raster/man/merge.Rd
===================================================================
--- pkg/raster/man/merge.Rd	                        (rev 0)
+++ pkg/raster/man/merge.Rd	2009-03-07 08:24:49 UTC (rev 319)
@@ -0,0 +1,53 @@
+\name{merge}
+
+\docType{methods}
+\alias{merge}
+\alias{merge,RasterLayer,RasterLayer-method}
+\title{ 
+Merge RasterLayers
+
+}
+
+\description{
+Merge RasterLayers to form a new RasterLayer with a larger spatial extent
+
+This is a method for the generic function in Package `base'
+
+}
+
+\section{Methods}{
+\describe{
+\code{merge(x, y, ..., tolerance=0.05, filename="", overwrite=FALSE) }
+
+\item{x,y}{"RasterLayer"}{
+  \item{...}{additional RasterLayer objects}
+  \item{tolerance}{difference permissable (relative to the cell resolution) for objects to be 'equal'. See ?all.equal}
+  \item{filename}{output filename for a new raster}
+  \item{overwrite}{if \code{TRUE}, the file will be overwritten if it exists}
+}} }
+
+\details{
+The RasterLayer objects must have the same origin and resolution. In areas where the RasterLayers overlap, the values of the RasterLayer that is first in the sequence will be retained. 
+}
+
+\value{
+A new RasterLayer object (in the R environment), and in some cases the side effect of a new file on disk.
+}
+\author{Robert J. Hijmans}
+
+\seealso{ \code{\link[raster]{crop}}, \code{\link[raster]{expand}}}
+
+\examples{
+r1 <- raster(xmx=-150, ymn=60, ncols=30, nrows=30)
+r1[] <- 1:ncell(r1)
+r2 <- raster(xmn=-100, xmx=-50, ymx=50, ymn=30)
+r2 <- setRes(r2, xres(r1), yres(r1))
+r2[] <- 1:ncell(r2)
+rm <- merge(r1, r2)
+}
+
+\keyword{methods}
+\keyword{spatial}
+
+
+

Deleted: pkg/raster/man/overlay-methods.Rd
===================================================================
--- pkg/raster/man/overlay-methods.Rd	2009-03-06 12:19:50 UTC (rev 318)
+++ pkg/raster/man/overlay-methods.Rd	2009-03-07 08:24:49 UTC (rev 319)
@@ -1,69 +0,0 @@
-\name{overlay}
-\docType{methods}
-
-\alias{overlay}
-\alias{overlay,RasterLayer,RasterLayer-method}
-\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. 
-
-You should supply a function \code{fun} to set the way that the RasterLayers are combined. The number of arguments in the function must match the number of RasterLayer objects.
-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{...}
-
-}
-
-\section{Methods}{
-
-\code{overlay(x, y, ..., fun, filename="", overwrite=FALSE,  filetype='raster', datatype='FLT4S')}
-
-  \item{x, y}{RasterLayer objects}
-  \item{...}{  additional RasterLayer objects and
-  \item{fun}{ the function to be appliepd. This should be a function that takes two numbers as an argument }
-  \item{filename}{ filename for the output raster. A valid filename must be provided when the data of the input rasters are on disk }
-  \item{overwrite}{logical. If \code{TRUE}, existing files will be overwritten}
-  \item{filetype}{output file type. Either 'raster', 'ascii' or a supported GDAL 'driver' name see \code{\link[raster]{writeRaster}}}
-}
-}
-
-\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 (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)
-}
-
-\seealso{ \code{\link[raster]{Arith-methods}} }
-
-
-\author{
-Robert J. Hijmans 
-}
-
-\examples{
-r <- raster()
-r1 <- init(r)
-r2 <- init(r)
-r3 <- overlay(r1, r2, fun=function(x,y){return(x+y)})
-
-# long version for multiplication
-r4 <- overlay(r1, r2, fun=function(x,y){return(x*y)} )
-# short function doing the same, if values can be loaded into ram memory
-r5 <- r1 * r2
-
-# multiplication with more than two layers (make sure the number of RasterLayers matches the arguments of 'fun'
-r6 <- overlay(r1, r2, r3, r4, fun=function(a,b,c,d){return(a*b+c*d)} )  
-
-}
- 
-\keyword{methods}
-\keyword{spatial}

Added: pkg/raster/man/overlay.Rd
===================================================================
--- pkg/raster/man/overlay.Rd	                        (rev 0)
+++ pkg/raster/man/overlay.Rd	2009-03-07 08:24:49 UTC (rev 319)
@@ -0,0 +1,69 @@
+\name{overlay}
+\docType{methods}
+
+\alias{overlay}
+\alias{overlay,RasterLayer,RasterLayer-method}
+\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. 
+
+You should supply a function \code{fun} to set the way that the RasterLayers are combined. The number of arguments in the function must match the number of RasterLayer objects.
+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{...}
+
+}
+
+\section{Methods}{
+
+\code{overlay(x, y, ..., fun, filename="", overwrite=FALSE,  filetype='raster', datatype='FLT4S')}
+
+  \item{x, y}{RasterLayer objects}
+  \item{...}{  additional RasterLayer objects and
+  \item{fun}{ the function to be appliepd. This should be a function that takes two numbers as an argument }
+  \item{filename}{ filename for the output raster. A valid filename must be provided when the data of the input rasters are on disk }
+  \item{overwrite}{logical. If \code{TRUE}, existing files will be overwritten}
+  \item{filetype}{output file type. Either 'raster', 'ascii' or a supported GDAL 'driver' name see \code{\link[raster]{writeRaster}}}
+}
+}
+
+\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 (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)
+}
+
+\seealso{ \code{\link[raster]{Arith-methods}} }
+
+
+\author{
+Robert J. Hijmans 
+}
+
+\examples{
+r <- raster()
+r1 <- init(r)
+r2 <- init(r)
+r3 <- overlay(r1, r2, fun=function(x,y){return(x+y)})
+
+# long version for multiplication
+r4 <- overlay(r1, r2, fun=function(x,y){return(x*y)} )
+# short function doing the same, if values can be loaded into ram memory
+r5 <- r1 * r2
+
+# multiplication with more than two layers (make sure the number of RasterLayers matches the arguments of 'fun'
+r6 <- overlay(r1, r2, r3, r4, fun=function(a,b,c,d){return(a*b+c*d)} )  
+
+}
+ 
+\keyword{methods}
+\keyword{spatial}

Modified: pkg/raster/man/pointdistance.Rd
===================================================================
--- pkg/raster/man/pointdistance.Rd	2009-03-06 12:19:50 UTC (rev 318)
+++ pkg/raster/man/pointdistance.Rd	2009-03-07 08:24:49 UTC (rev 319)
@@ -1,28 +1,35 @@
-\name{distance}
+\name{pointDistance}
+
 \alias{distanceEuclidean}
 \alias{distanceGreatcircle}
-\title{ Calculate geographic distance }
+
+\title{distance between points}
+
 \description{
   Calculate geographic distance between two points on a sphere (distanceGreatcircle) or on a plane (distanceEuclidean).
 }
+
 \usage{
 distanceEuclidean(point1, point2)
 distanceGreatcircle(point1, point2, r = 6378137)
 }
+
 \arguments{
-  \item{point1}{  x and y coordinate of first (set of) point(s), either as c(x, y) or as matrix(ncol=2) in degrees for greatcircle, in meters (or similar) for euclidean }
-  \item{point2}{  x and y coordinate of second (set of) second point(s). Like point1 }
-  \item{r}{  radius of the world (modeled as a sphere), in meters }
+  \item{point1}{x and y coordinate(s) of first (set of) point(s), either as c(x, y) or as matrix(ncol=2) in degrees for greatcircle, in meters (or similar) for euclidean }
+  \item{point2}{x and y coordinate(s) of second (set of) second point(s). Like point1 }
+  \item{r}{radius of the world (modeled as a sphere), in meters }
 }
 \details{
   A sphere is an approximation for the earth (a spheroid) and distanceGreatcircle can thus be used with geographic 
-  coordinates (latitude & longitude). There are probably better functions available, that use a datum, in other packages.
+  coordinates (latitude & longitude). There are probably more refined functions in other packages.
   You can use distanceEuclidean for coordinates of a map projection such as UTM (but note
   that in some projections distance is distorted). 
 }
+
 \value{
   Distance in meters (great circle distance) or map-units (typically meters)
 }
+
 \author{Robert J. Hijmans }
 
 
@@ -30,4 +37,5 @@
    distanceEuclidean(c(0, 0), c(1, 1))
    distanceGreatcircle(c(0, 0), c(1, 1))
 }
+
 \keyword{ spatial }

Added: pkg/raster/man/replacement.Rd
===================================================================
--- pkg/raster/man/replacement.Rd	                        (rev 0)
+++ pkg/raster/man/replacement.Rd	2009-03-07 08:24:49 UTC (rev 319)
@@ -0,0 +1,43 @@
+\name{replaceMethods}
+\docType{methods}
+
+\alias{[,RasterLayer-method}
+\alias{[,RasterLayer,ANY,ANY-method}
+\alias{[,RasterLayer,ANY,missing-method}
+
+\alias{[[,RasterLayer,ANY,ANY-method}
+
+\alias{[<-,RasterLayer-method}
[TRUNCATED]

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


More information about the Raster-commits mailing list