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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Feb 2 07:43:00 CET 2009


Author: rhijmans
Date: 2009-02-02 07:43:00 +0100 (Mon, 02 Feb 2009)
New Revision: 235

Added:
   pkg/raster/man/disaggregate.Rd
Modified:
   pkg/raster/NAMESPACE
   pkg/raster/R/Overlay.R
   pkg/raster/R/aggregate.R
   pkg/raster/man/aggregate.Rd
   pkg/raster/man/overlay.Rd
Log:


Modified: pkg/raster/NAMESPACE
===================================================================
--- pkg/raster/NAMESPACE	2009-02-02 04:47:28 UTC (rev 234)
+++ pkg/raster/NAMESPACE	2009-02-02 06:43:00 UTC (rev 235)
@@ -1,6 +1,7 @@
 importFrom("methods", Arith, Compare, Logic, Math)
 importFrom("graphics", hist, plot)
+importFrom("stats", aggregate)
 importFrom("sp", bbox, overlay, Spatial, SpatialPixels, SpatialPixelsDataFrame, SpatialGrid, SpatialGridDataFrame)
 exportClasses(BoundingBox, BasicRaster, Raster, RasterLayer, RasterStack)
-exportMethods(show, summary, plot, hist, ncol, nrow, dim, overlay, bbox)
+exportMethods(aggregate, show, summary, plot, hist, ncol, nrow, dim, overlay, bbox)
 exportPattern("^[^\\.]")
\ No newline at end of file

Modified: pkg/raster/R/Overlay.R
===================================================================
--- pkg/raster/R/Overlay.R	2009-02-02 04:47:28 UTC (rev 234)
+++ pkg/raster/R/Overlay.R	2009-02-02 06:43:00 UTC (rev 235)
@@ -5,10 +5,16 @@
 # Licence GPL v3
 
 
+
+if (!isGeneric("overlay")) {
+	setGeneric("overlay", function(x, y, ..., fun, filename, overwrite, asInt)
+		standardGeneric("overlay"))
+}	
+
+
 setMethod('overlay', signature(x='RasterLayer', y='RasterLayer'), 
 function(x, y, ..., fun=sum, 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 }

Modified: pkg/raster/R/aggregate.R
===================================================================
--- pkg/raster/R/aggregate.R	2009-02-02 04:47:28 UTC (rev 234)
+++ pkg/raster/R/aggregate.R	2009-02-02 06:43:00 UTC (rev 235)
@@ -7,14 +7,8 @@
 
 
 
-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, ...)  {
+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') }

Modified: pkg/raster/man/aggregate.Rd
===================================================================
--- pkg/raster/man/aggregate.Rd	2009-02-02 04:47:28 UTC (rev 234)
+++ pkg/raster/man/aggregate.Rd	2009-02-02 06:43:00 UTC (rev 235)
@@ -1,19 +1,17 @@
 \name{aggregate}
 \alias{aggregate,RasterLayer-method}
 \alias{aggregate}
-\alias{disaggregate}
 
-\title{Change raster database}
+\title{Aggregate}
 \description{
-	(Dis)aggregate a raster to create a new raster 
+	aggregate a raster to create a new raster with a lower resolution
 }
 \usage{
-aggregate(raster, fact = 2, fun = mean, expand = TRUE, rm.NA = TRUE, filename="", overwrite=FALSE, asInt = FALSE) 
-disaggregate(raster, fact=2, filename="", overwrite=FALSE) 
+aggregate(x, fact = 2, fun = mean, expand = TRUE, rm.NA = TRUE, filename="", overwrite=FALSE, asInt = FALSE) 
 }
 
 \arguments{
-  \item{raster}{a RasterLayer object}
+  \item{x}{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{fact}{degree of aggregation or disaggregation expressed as number of cells (horizontally and vertically). See details}
@@ -25,13 +23,10 @@
 
 \details{
  In aggregation \code{fact = 2} will result in a grid with 2 x 2 = 4 times fewer cells, while in disaggregation 4 times more cells will be created.
- In disaggregation fact can be a single integer or two integers c(x,y), in which case the first one is the horizontal disaggregation factor and y the vertical disaggreation factor
- 
- 
 }
 
 \value{
-  a new RasterLayer object (in the R environment) which is in some cases written to disk 
+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 \email{r.hijmans at gmail.com}}
 
@@ -39,7 +34,6 @@
 	r <- raster()
 	r <- setValues(r, runif(ncell(r)))
 	ra <- aggregate(r, fact=10, fun=max)
-	rd <- disaggregate(ra, 3)
 }
 
 \keyword{spatial}

Added: pkg/raster/man/disaggregate.Rd
===================================================================
--- pkg/raster/man/disaggregate.Rd	                        (rev 0)
+++ pkg/raster/man/disaggregate.Rd	2009-02-02 06:43:00 UTC (rev 235)
@@ -0,0 +1,36 @@
+\name{disaggregate}
+\alias{disaggregate}
+
+\title{Disaggregate}
+\description{
+	Disaggregate a raster to create a new raster 
+}
+\usage{
+disaggregate(raster, fact=2, filename="", overwrite=FALSE) 
+}
+
+\arguments{
+  \item{raster}{a RasterLayer object}
+  \item{filename}{output filename for a new raster}
+  \item{fact}{degree of aggregation or disaggregation expressed as number of cells (horizontally and vertically). See details}
+  \item{overwrite}{if TRUE, "filename" will be overwritten if it exists}
+}
+
+\details{
+ Fact can be a single integer or two integers c(x,y), in which case the first one is the horizontal disaggregation factor and y the vertical disaggreation factor
+}
+
+\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 \email{r.hijmans at gmail.com}}
+
+\examples{
+	r <- raster(ncols=10, nrows=10)
+	rd <- disaggregate(r, fact=c(10, 5))
+	ncol(rd)
+	nrow(rd)	
+}
+
+\keyword{spatial}
+

Modified: pkg/raster/man/overlay.Rd
===================================================================
--- pkg/raster/man/overlay.Rd	2009-02-02 04:47:28 UTC (rev 234)
+++ pkg/raster/man/overlay.Rd	2009-02-02 06:43:00 UTC (rev 235)
@@ -1,6 +1,5 @@
 \name{overlay}
 \alias{overlay,RasterLayer,RasterLayer-method}
-\alias{overlay}
 
 \title{ Raster overlay calculation }
 \description{



More information about the Raster-commits mailing list