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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Feb 2 05:44:38 CET 2009


Author: rhijmans
Date: 2009-02-02 05:44:38 +0100 (Mon, 02 Feb 2009)
New Revision: 233

Added:
   pkg/raster/man/crop.Rd
   pkg/raster/man/expand.Rd
   pkg/raster/man/merge.Rd
Removed:
   pkg/raster/man/change.extent.Rd
Modified:
   pkg/raster/R/Merge.R
   pkg/raster/R/Overlay.R
   pkg/raster/R/aggregate.R
   pkg/raster/R/makeProjString.R
   pkg/raster/man/LinesToRaster.Rd
   pkg/raster/man/PolygonsToRaster.Rd
   pkg/raster/man/adjacency.Rd
   pkg/raster/man/aggregate.Rd
   pkg/raster/man/map.Rd
   pkg/raster/man/overlay.Rd
   pkg/raster/man/project.Rd
Log:


Modified: pkg/raster/R/Merge.R
===================================================================
--- pkg/raster/R/Merge.R	2009-02-02 02:27:33 UTC (rev 232)
+++ pkg/raster/R/Merge.R	2009-02-02 04:44:38 UTC (rev 233)
@@ -3,7 +3,7 @@
 # International Rice Research Institute
 #contact: r.hijmans at gmail.com
 # Date : October 2008
-# Version 0.7
+# Version 0.8
 # Licence GPL v3
 
 
@@ -40,7 +40,27 @@
 
 
 
-Merge <- function(rasters, tolerance=0.05, filename="", overwrite=FALSE) {
+if (!isGeneric("merge")) {
+	setGeneric("merge", function(x, y, ...)
+		standardGeneric("merge"))
+}	
+
+
+setMethod('merge', signature(x='RasterLayer', y='RasterLayer'), 
+function(x,y,...,tolerance=0.05, filename="", overwrite=FALSE ){ 
+	
+	rasters <- list(...)
+	if (length(rasters) > 0) {
+		for (i in 1:length(rasters)) {
+			if (class(rasters[[i]]) != 'RasterLayer') {
+				print(class(rasters[[i]]))
+				stop('only supply RasterLayer objects as ... arguments')
+			}
+		}
+	}
+	rasters <- c(x, y, rasters)
+	
+			
 	compare(rasters, bb=FALSE, rowcol=FALSE, orig=TRUE, res=TRUE, tolerance=tolerance)
 	bb <- .outerBox(rasters)
 	outraster <- setRaster(rasters[[1]], filename)
@@ -94,3 +114,6 @@
 	if (filename(outraster) == '') { outraster <- setValues(outraster, v) }
 	return(outraster)
 }
+)
+
+

Modified: pkg/raster/R/Overlay.R
===================================================================
--- pkg/raster/R/Overlay.R	2009-02-02 02:27:33 UTC (rev 232)
+++ pkg/raster/R/Overlay.R	2009-02-02 04:44:38 UTC (rev 233)
@@ -4,15 +4,11 @@
 # Version 0,1
 # Licence GPL v3
 
+
 setMethod('overlay', signature(x='RasterLayer', y='RasterLayer'), 
-	function(x, y, ...){ 
-		return(Overlay(x, y, ...) )
-	}
-)
+function(x, y, ..., fun=sum, filename="", overwrite=FALSE, asInt = FALSE){ 
 
 
-Overlay <- function(x, y, ..., fun, filename="", overwrite=FALSE, asInt = FALSE){ 
-
 	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 }
@@ -104,4 +100,4 @@
 	} 
 	return(outraster)
 }
-
+)

Modified: pkg/raster/R/aggregate.R
===================================================================
--- pkg/raster/R/aggregate.R	2009-02-02 02:27:33 UTC (rev 232)
+++ pkg/raster/R/aggregate.R	2009-02-02 04:44:38 UTC (rev 233)
@@ -5,7 +5,16 @@
 # Version 0,7
 # Licence GPL v3
 
-Aggregate <- function(raster, fact = 2, fun = mean, expand = TRUE, rm.NA = TRUE, filename="", overwrite=FALSE, asInt = FALSE)  {
+
+
+if (!isGeneric("aggregate")) {
+	setGeneric("aggregate", function(x, ...)
+		standardGeneric("aggregate"))
+}	
+
+
+setMethod('aggregate', signature(x='RasterLayer'), 
+function(x, fact = 2, fun = mean, expand = TRUE, rm.NA = TRUE, filename="", overwrite=FALSE, asInt = FALSE, ...)  {
 	if (length(fact)==1) {
 		fact <- round(fact)
 		if (fact < 2) { stop('fact should be > 1') }
@@ -20,67 +29,68 @@
 	}
 
 	if (expand) {
-		rsteps <- as.integer(ceiling(nrow(raster)/yfact))
-		csteps <- as.integer(ceiling(ncol(raster)/xfact))
+		rsteps <- as.integer(ceiling(nrow(x)/yfact))
+		csteps <- as.integer(ceiling(ncol(x)/xfact))
 	} else 	{
-		rsteps <- as.integer(floor(nrow(raster)/yfact))
-		csteps <- as.integer(floor(ncol(raster)/xfact))
+		rsteps <- as.integer(floor(nrow(x)/yfact))
+		csteps <- as.integer(floor(ncol(x)/xfact))
 	}
-	ymn <- ymax(raster) - rsteps * yfact * yres(raster)
-	xmx <- xmin(raster) + csteps * xfact * xres(raster)
+	
+	ymn <- ymax(x) - rsteps * yfact * yres(x)
+	xmx <- xmin(x) + csteps * xfact * xres(x)
 		
-	outraster <- setRaster(raster, filename)
-	bndbox <- newBbox(xmin(raster), xmx, ymn, ymax(raster))
-	outraster <- setBbox(outraster, bndbox, keepres=F)
-	outraster <- setRowCol(outraster, nrows=rsteps, ncols=csteps) 
+	outRaster <- setRaster(x, filename)
+	bndbox <- newBbox(xmin(x), xmx, ymn, ymax(x))
+	outRaster <- setBbox(outRaster, bndbox, keepres=F)
+	outRaster <- setRowCol(outRaster, nrows=rsteps, ncols=csteps) 
 	
-	if (asInt) { outraster <- setDatatype(outraster, 'integer') }
+	if (asInt) { outRaster <- setDatatype(outRaster, 'integer') }
 	
-	if (dataContent(raster) == 'all') {	
-		cols <- rep(rep(1:csteps, each=xfact)[1:ncol(raster)], times=nrow(raster))
-		rows <- rep(1:rsteps, each=ncol(raster) * yfact)[1:ncell(raster)]
-		cells <- cellFromRowCol(raster, rows, cols)
+	if (dataContent(x) == 'all') {	
+		cols <- rep(rep(1:csteps, each=xfact)[1:ncol(x)], times=nrow(x))
+		rows <- rep(1:rsteps, each=ncol(x) * yfact)[1:ncell(x)]
+		cells <- cellFromRowCol(x, rows, cols)
 		
-		if (rm.NA) { outraster <- setValues(outraster, as.vector(tapply(values(raster), cells, function(x){fun(na.omit(x))}))) 
-		} else {outraster <- setValues(outraster, as.vector(tapply(values(raster), cells, fun))) }
+		if (rm.NA) { outRaster <- setValues(outRaster, as.vector(tapply(values(x), cells, function(x){fun(na.omit(x))}))) 
+		} else {outRaster <- setValues(outRaster, as.vector(tapply(values(x), cells, fun))) }
 
-		if (filename(outraster) != "") {writeRaster(outraster, overwrite=overwrite)}
+		if (filename(outRaster) != "") {writex(outRaster, overwrite=overwrite)}
 		
-	} else if ( dataSource(raster) == 'disk') { 
+	} else if ( dataSource(x) == 'disk') { 
 	
-		cols <- rep(rep(1:csteps,each=xfact)[1:ncol(raster)], times=yfact)
-		rows <- rep(1, each=(ncol(raster) * yfact))
+		cols <- rep(rep(1:csteps,each=xfact)[1:ncol(x)], times=yfact)
+		rows <- rep(1, each=(ncol(x) * yfact))
 		v <- vector(length=0)
 		for (r in 1:rsteps) 
 		{
 			startrow <- 1 + (r - 1) * yfact
 			if ( r==rsteps) {
-				endrow <- min(nrow(raster), startrow + yfact - 1)
+				endrow <- min(nrow(x), startrow + yfact - 1)
 				nrows <- endrow - startrow + 1
-				theserows <- (startrow * rows)[1:(ncol(raster)*nrows)]
-				cols <- cols[1:(ncol(raster)*nrows)]
+				theserows <- (startrow * rows)[1:(ncol(x)*nrows)]
+				cols <- cols[1:(ncol(x)*nrows)]
 			} else {
 				nrows = yfact
 				theserows <- startrow * rows
 			}	
-			raster <- readRows(raster, startrow = startrow, nrows = nrows)
-			cells <- cellFromRowCol(raster, theserows, cols)
+			x <- readRows(x, startrow = startrow, nrows = nrows)
+			cells <- cellFromRowCol(x, theserows, cols)
 			
-			if (rm.NA) { vals <- tapply(values(raster), cells, function(x){fun(na.omit(x))} ) 
-			} else { vals <- tapply(values(raster), cells, fun) }
+			if (rm.NA) { vals <- tapply(values(x), cells, function(x){fun(na.omit(x))} ) 
+			} else { vals <- tapply(values(x), cells, fun) }
 			vals <- as.vector(vals)
 
-			if (filename(outraster) == "") {
+			if (filename(outRaster) == "") {
 				v <- c(v, vals)
 			} else {
-				outraster <- setValues(outraster, vals, r)
-				outraster <- writeRaster(outraster, overwrite=overwrite)
+				outRaster <- setValues(outRaster, vals, r)
+				outRaster <- writex(outRaster, overwrite=overwrite)
 			}
 		} 
-		if (filename(outraster) == "") { 
-			outraster <- setValues(outraster, v) 
+		if (filename(outRaster) == "") { 
+			outRaster <- setValues(outRaster, v) 
 		}
 	}
-	return(outraster)
+	return(outRaster)
 }
-
+)

Modified: pkg/raster/R/makeProjString.R
===================================================================
--- pkg/raster/R/makeProjString.R	2009-02-02 02:27:33 UTC (rev 232)
+++ pkg/raster/R/makeProjString.R	2009-02-02 04:44:38 UTC (rev 233)
@@ -48,7 +48,8 @@
 			pstr <- paste(pstr, " +ellps=", ellipsoid, sep="")
 #			ellipname <- ell[which(ell[,1]==ellipsoid), 2]
 		}
-	} else if (datum != "") {
+	}
+	if (datum != "") {
 		if (!(datum %in% dat[,1])) { 
 			stop("unknown datum. See projInfo('datum')") 
 		} else {
@@ -57,9 +58,7 @@
 		}
 	}
 	cat("Projection: ", projname[1], "\n")
-	
 	crs <- newCRS(pstr)
-		
 	if (asText) { 
 		return(trim(crs at projargs))
 	} else {
@@ -67,6 +66,3 @@
 	}
 }
 
-# newprj2 <- makeProj("lcc", "lat_1=48", "lat_2=33", "lon_0=-100", asText=T)
-
-

Modified: pkg/raster/man/LinesToRaster.Rd
===================================================================
--- pkg/raster/man/LinesToRaster.Rd	2009-02-02 02:27:33 UTC (rev 232)
+++ pkg/raster/man/LinesToRaster.Rd	2009-02-02 04:44:38 UTC (rev 233)
@@ -26,9 +26,9 @@
 
 \author{Robert J. Hijmans \email{r.hijmans at gmail.com}}
 
-\seealso{ \code{\link[rgdal]{rgdal}} }
-\examples{
+\seealso{ \code{\link[raster]{linesToRaster}}, \code{\link[raster]{pointsToRaster}}}
 
+\examples{
 cds1 <- rbind(c(-50,0), c(0,60), c(40,5), c(15,-45), c(-10,-25))
 cds2 <- rbind(c(80,20), c(140,60), c(160,0), c(140,-55))
 cds3 <- rbind(c(-180,-20), c(-140,-60), c(-60,-20), c(-140,55))
@@ -39,7 +39,6 @@
 r <- linesToRaster(lines, r)
 plot(r)
 plot(lines, add=TRUE)
-
 }
 
 \keyword{ spatial }

Modified: pkg/raster/man/PolygonsToRaster.Rd
===================================================================
--- pkg/raster/man/PolygonsToRaster.Rd	2009-02-02 02:27:33 UTC (rev 232)
+++ pkg/raster/man/PolygonsToRaster.Rd	2009-02-02 04:44:38 UTC (rev 233)
@@ -3,9 +3,9 @@
 \alias{polygonsToRaster}
 \alias{polygonsToRaster2}
 
-\title{ Transform polygons to a raster }
+\title{ Polygons to raster conversion}
 \description{
-  Two implementations of a polygon to raster conversion (number 2 should be slowest in most cases)
+Two algorithms for polygon to raster conversion. The polygons are rasterized. Either values associated with each polygon, or a polygon ID are transferred. Holes in polygons are recognized by polygonsToRaster, but not by polygonsToRaster2.
 }
 \usage{
 polygonsToRaster(spPolys, raster, field=0, filename="", overwrite=FALSE, updateRaster=FALSE, updateValue="NA") 
@@ -23,14 +23,14 @@
 }
 
 \details{
-	For SpatialPolygons, the 'field' argument is ignored. The polygon index is tranferred.
+For SpatialPolygons, the 'field' argument is ignored. The polygon index is tranferred.
 }
 
-\author{Robert J. Hijmans \email{r.hijmans at gmail.com}}
+\author{Robert J. Hijmans}
 
-\seealso{ \code{\link[raster]{lines to raster}} }
-\examples{ 
+\seealso{ \code{\link[raster]{linesToRaster}}, \code{\link[raster]{pointsToRaster}}}
 
+\examples{ 
 cds1 <- rbind(c(-50,0), c(0,60), c(40,5), c(15,-45), c(-10,-25), c(-50,0))
 cds2 <- rbind(c(80,20), c(140,60), c(160,0), c(140,-55), c(80,20))
 cds3 <- rbind(c(-180,-20), c(-140,-60), c(-60,-20), c(-140,55), c(-180,-20))
@@ -47,10 +47,9 @@
 addpoly <- as(addpoly, "SpatialPolygonsDataFrame")
 addpoly at data[1,1] <- 10
 r2 <- polygonsToRaster(addpoly, r, field=1, updateRaster=TRUE, updateValue="NA")
-plot(r2)
+#plot(r2)
 #plot(polys, border="blue", lwd=2, add=TRUE)
 #plot(addpoly, add=TRUE, border="red", lwd=2)
-
 }
 
 \keyword{ spatial }

Modified: pkg/raster/man/adjacency.Rd
===================================================================
--- pkg/raster/man/adjacency.Rd	2009-02-02 02:27:33 UTC (rev 232)
+++ pkg/raster/man/adjacency.Rd	2009-02-02 04:44:38 UTC (rev 233)
@@ -13,7 +13,7 @@
   \item{raster}{an object of the Raster family}
   \item{fromCells}{a vector of cell numbers for which adjacent cells should be calculated}
   \item{toCells}{a vector of cell numbers from which adjacent cells are selected}
-  \item{directions}{in how many direction cells should be connected: 4, 8 or 16; or Bishop}
+  \item{directions}{in how many direction cells should be connected: 4, 8 or 16; or "Bishop"}
 }
 
 \details{
@@ -29,17 +29,16 @@
 \author{Jacob van Etten \email{jacobvanetten at yahoo.com}}
 
 \examples{
-	rs <- raster(nrows=10, ncols=10)
-	adj <- adjacency(raster = rs, fromCells = c(1,30,55,72,100), toCells = c(1:ncell(rs)), directions=4) 
+rs <- raster(nrows=10, ncols=10)
+adj <- adjacency(raster = rs, fromCells = c(1,30,55,72,100), toCells = c(1:ncell(rs)), directions=4) 
 	
-	#Visualize the outcome in a raster
-	v <- vector(length=ncell(rs))
-	v[c(1,30,55,72,100)] <- 1
-	v[adj[,2]] <- 2
-	rs <- setValues(rs, v)
-	plot(rs)
+#put the result in a RasterLayer
+v <- vector(length=ncell(rs))
+v[c(1,30,55,72,100)] <- 1
+v[adj[,2]] <- 2
+rs <- setValues(rs, v)
+plot(rs)
 
-	adjbis <- adjacency(raster = rs, fromCells = c(1,30,55,72,100), toCells = c(1:ncell(rs)), direction='Bishop') 
 }
 
 \keyword{spatial}

Modified: pkg/raster/man/aggregate.Rd
===================================================================
--- pkg/raster/man/aggregate.Rd	2009-02-02 02:27:33 UTC (rev 232)
+++ pkg/raster/man/aggregate.Rd	2009-02-02 04:44:38 UTC (rev 233)
@@ -1,20 +1,21 @@
 \name{aggregate}
-\alias{Aggregate}
+\alias{aggregate,RasterLayer-method}
+alias{aggregate}
 \alias{disaggregate}
 
 \title{Change raster database}
 \description{
-	(Dis)aggregated a raster to create a new raster 
+	(Dis)aggregate a raster to create a new raster 
 }
 \usage{
-Aggregate(raster, fact = 2, fun = mean, expand = TRUE, rm.NA = TRUE, filename="", overwrite=FALSE, asInt = FALSE) 
+aggregate(raster, fact = 2, fun = mean, expand = TRUE, rm.NA = TRUE, filename="", overwrite=FALSE, asInt = FALSE) 
 disaggregate(raster, fact=2, filename="", overwrite=FALSE) 
 }
 
 \arguments{
   \item{raster}{a RasterLayer object}
   \item{filename}{output filename for a new raster}
-  \item{fun}{function used to Aggregate values. It should return one number. E.g. mean or max}
+  \item{fun}{function used to aggregate values. It should return one number. E.g. mean or max}
   \item{fact}{degree of aggregation or disaggregation expressed as number of cells (horizontally and vertically). See details}
   \item{expand}{if \code{expand == TRUE} grids will get larger if \code{factor} if the number of the division of the columns or rows with factor does not return an integer}
   \item{rm.NA}{if \code{rm.NA == TRUE}, remove NA cells from calculations}
@@ -37,7 +38,7 @@
 \examples{
 	r <- raster()
 	r <- setValues(r, runif(ncell(r)))
-	ra <- Aggregate(r, fact=10, fun=max)
+	ra <- aggregate(r, fact=10, fun=max)
 	rd <- disaggregate(ra, 3)
 }
 

Deleted: pkg/raster/man/change.extent.Rd
===================================================================
--- pkg/raster/man/change.extent.Rd	2009-02-02 02:27:33 UTC (rev 232)
+++ pkg/raster/man/change.extent.Rd	2009-02-02 04:44:38 UTC (rev 233)
@@ -1,52 +0,0 @@
-\name{change extent}
-\alias{crop}
-\alias{Merge}
-\alias{expand}
-
-\title{Change raster database}
-\description{
-	Use existing raster(s) to create a new raster with different spatial extent or resolution
-}
-\usage{
-crop(raster, bndbox, filename="", overwrite=FALSE) 
-expand(raster, bndbox, filename="", overwrite=FALSE)
-Merge(rasters, tolerance=0.05, filename="", overwrite=FALSE) 
-}
-
-\arguments{
-  \item{raster}{a RasterLayer object}
-  \item{rasters}{a list of RasterLayer objects}
-  \item{bndbox}{bounding box used to crop a raster. Any object that is or has a bounding box (see below)}
-  \item{filename}{output filename for a new raster}
-  \item{overwrite}{if TRUE, "filename" will be overwritten if it exists}
-  \item{tolerance}{difference permissable (relative to the cell resolution) for objects to be 'equal'. See ?all.equal}
-}
-
-\details{
- Objects that have bounding boxes include RasterLayer, and other objects descending from the Spatial class in the sp package. 
- You can check this with getBbox(object)
- They can be created with the function newBbox
- 
-}
-
-\value{
-  a new RasterLayer object (in the R environment) which is in some cases written to disk 
-}
-\author{Robert J. Hijmans \email{r.hijmans at gmail.com}}
-
-\examples{
-	rs <- raster()
-	rs <- setValues(rs, runif(ncell(rs)))
-#	map(rsa)
-	bb1 <- newBbox(-180, -150, 60, 90)
-	rsc1 <- crop(rs, bb1)	
-	bb2 <- newBbox(0, 50, 0, 90)
-	rsc2 <- crop(rs, bb2)	
-	rsc <- Merge(c(rsc1, rsc2))
-#	map(rsc)
-#	rs provides the bounding box for expand
-	rse <- expand(rsc, rs)
-}
-
-\keyword{spatial}
-

Added: pkg/raster/man/crop.Rd
===================================================================
--- pkg/raster/man/crop.Rd	                        (rev 0)
+++ pkg/raster/man/crop.Rd	2009-02-02 04:44:38 UTC (rev 233)
@@ -0,0 +1,40 @@
+\name{crop}
+\alias{crop}
+
+\title{Crop the extent of a RasterLayer}
+\description{
+crop returns a subset of the input RasterLayer as specified by a the supplied bounding box (or object that has a bounding box). Areas in the bounding box outside of the intput RasterLayer are ignored. 
+}
+\usage{
+crop(raster, bndbox, filename="", overwrite=FALSE) 
+}
+
+\arguments{
+  \item{raster}{a RasterLayer object}
+  \item{bndbox}{BoundingBox object, or any object that is or has a bounding box (see below)}
+  \item{filename}{character. Output filename for a new raster}
+  \item{overwrite}{if \code{TRUE}, the file will be overwritten if it exists}
+}
+
+\details{
+ Objects that have a BoundingBox object include RasterLayer, RasterStack. They can also be extracted from objects descending from the Spatial class in the sp package. 
+ You can check this with getBbox(object). New BoundingBox objects can be reated with the function newBbox().
+}
+
+\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]{expand}}, \code{\link[raster]{Merge}}
+}
+
+\examples{
+r <- raster(nrow=45, ncol=90)
+r[] <- 1:ncell(r)
+bb <- newBbox(-160, 10, 30, 60)
+rc <- crop(r, bb)	
+}
+
+\keyword{spatial}

Added: pkg/raster/man/expand.Rd
===================================================================
--- pkg/raster/man/expand.Rd	                        (rev 0)
+++ pkg/raster/man/expand.Rd	2009-02-02 04:44:38 UTC (rev 233)
@@ -0,0 +1,39 @@
+\name{expand}
+\alias{expand}
+
+\title{Expand the extent of a RasterLayer}
+\description{
+expand returns an elarged RasterLayer. The new RasterLayer has the extreme minimum and maximum coordinates of the input RasterLayer and BoundingBox object. Thus, all of the cells of the original raster are inlcluded.
+}
+\usage{
+expand(raster, bndbox, filename="", overwrite=FALSE)
+}
+
+\arguments{
+  \item{raster}{a RasterLayer object}
+  \item{bndbox}{BoundingBox object, or any object that is or has a bounding box (see below)}
+  \item{filename}{character. Output filename for a new raster}
+  \item{overwrite}{if \code{TRUE}, the file will be overwritten if it exists}
+}
+
+\details{
+ Objects that have a BoundingBox object include RasterLayer, RasterStack. They can also be extracted from objects descending from the Spatial class in the sp package. 
+ You can check this with getBbox(object). New BoundingBox objects can be reated with the function newBbox().
+}
+
+\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]{Merge}}}
+
+
+\examples{
+r <- raster(xmn=-150, xmx=-120, ymx=60, ymn=30, nrow=30, ncol=30)
+r[] <- 1:ncell(r)
+bb <- newBbox(-180, 0, 0, 90)
+re <- expand(r, bb)
+}
+
+\keyword{spatial}

Modified: pkg/raster/man/map.Rd
===================================================================
--- pkg/raster/man/map.Rd	2009-02-02 02:27:33 UTC (rev 232)
+++ pkg/raster/man/map.Rd	2009-02-02 04:44:38 UTC (rev 233)
@@ -50,7 +50,7 @@
 	rs <- raster()
 	rs <- setValues(rs, runif(ncell(rs)))
 	map(rs)
-	rsa <- Aggregate(rs, fact=10, fun=max)
+	rsa <- aggregate(rs, fact=10, fun=max)
 	map(rsa)
  }
 

Added: pkg/raster/man/merge.Rd
===================================================================
--- pkg/raster/man/merge.Rd	                        (rev 0)
+++ pkg/raster/man/merge.Rd	2009-02-02 04:44:38 UTC (rev 233)
@@ -0,0 +1,45 @@
+\name{merge}
+\alias{merge,RasterLayer,RasterLayer-method}
+\alias{merge}
+
+\title{Merge RasterLayers}
+\description{
+Merge RasterLayers to form a new RasterLayer with a larger spatial extent
+}
+\usage{
+merge(x, y, ..., tolerance=0.05, filename="", overwrite=FALSE) 
+}
+
+\arguments{
+  \item{x}{a RasterLayer object}
+  \item{y}{a RasterLayer object}
+  \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{spatial}
+

Modified: pkg/raster/man/overlay.Rd
===================================================================
--- pkg/raster/man/overlay.Rd	2009-02-02 02:27:33 UTC (rev 232)
+++ pkg/raster/man/overlay.Rd	2009-02-02 04:44:38 UTC (rev 233)
@@ -1,6 +1,6 @@
 \name{overlay}
 \alias{overlay,RasterLayer,RasterLayer-method}
-\alias{Overlay}
+\alias{overlay}
 
 \title{ Raster overlay calculation }
 \description{
@@ -8,7 +8,7 @@
 }
 
 \usage{
-	Overlay(x, y, ..., fun, filename="", overwrite=FALSE, asInt=FALSE) 
+	overlay(x, y, ..., fun, filename="", overwrite=FALSE, asInt=FALSE) 
 }
 
 \arguments{
@@ -38,15 +38,15 @@
 	r <- raster()
 	r1 <- init(r)
 	r2 <- init(r)
-	r3 <- Overlay(r1, r2, fun=function(x,y){return(x+y)})
+	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)} )
+	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)} )	
+	r6 <- overlay(r1, r2, r3, r4, fun=function(a,b,c,d){return(a*b+c*d)} )	
 }	
 
 \keyword{ spatial }

Modified: pkg/raster/man/project.Rd
===================================================================
--- pkg/raster/man/project.Rd	2009-02-02 02:27:33 UTC (rev 232)
+++ pkg/raster/man/project.Rd	2009-02-02 04:44:38 UTC (rev 233)
@@ -16,9 +16,9 @@
 \arguments{
   \item{from}{a RasterLayer object}
   \item{to}{a BasicRaster object (or any Raster* object}
-  \item{method}{}
-  \item{overwrite}{}
-  \item{object}{}
+  \item{method}{character. Only 'nngb', or neirest neighbor, has been implmented sofar}
+  \item{overwrite}{if \code{TRUE}, the file will be overwritten if it exists}
+  \item{object}{BoundingBox or Raster* object}
   \item{projstring}{}
   \item{projection}{}
   \item{...}{parameters for the projection}  
@@ -52,17 +52,19 @@
 r <- setValues(r, 1:ncell(r))
 # proj.4 projection description
 newproj <- "+proj=lcc +lat_1=48 +lat_2=33 +lon_0=-100"
+# for debugging R-Forge...
+ drop(read.dcf(file=system.file("DESCRIPTION", package="rgdal"), fields=c("Version","Date")))
 # this is equivalent to
-#newproj2 <- makeProj("lcc", "lat_1=48", "lat_2=33", "lon_0=-100", ellp="WGS84", datum="")
+newproj2 <- makeProj("lcc", "lat_1=48", "lat_2=33", "lon_0=-100", ellps="WGS84", datum="")
 
 # create a new RasterLayer with a BoundingBox with the new projection
-#projras <- projectBbox(r, newproj)
+projras <- projectBbox(r, newproj)
 # Adjust the cell size 
-#projras <- setRes(projras, 100000)
+projras <- setRes(projras, 100000)
 # project the values of RasterLayer 'r' to the new RasterLayer 'projras'
-#projras <- projectRaster(r, projras)
+projras <- projectRaster(r, projras)
 # inverse projection, back to the properties of 'r'
-#inverse <- projectRaster(projras, r)
+inverse <- projectRaster(projras, r)
 
 }
 



More information about the Raster-commits mailing list