[Raster-commits] r132 - pkg/raster/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jan 13 13:09:13 CET 2009


Author: rhijmans
Date: 2009-01-13 13:09:13 +0100 (Tue, 13 Jan 2009)
New Revision: 132

Modified:
   pkg/raster/R/group.generic.functions.R
Log:
Added RasterLayer-numeric compare group generic functions

Modified: pkg/raster/R/group.generic.functions.R
===================================================================
--- pkg/raster/R/group.generic.functions.R	2009-01-13 11:41:44 UTC (rev 131)
+++ pkg/raster/R/group.generic.functions.R	2009-01-13 12:09:13 UTC (rev 132)
@@ -21,6 +21,26 @@
 )	
 
 
+setMethod("Compare", signature(e1='RasterLayer', e2='numeric'),
+	function(e1,e2){
+		if (!is.atomic(e2)) {
+			stop('second argument should be atomic (a single number)')
+		}
+		return(setRaster(e1, values=callGeneric(.getRasterValues(e1), rep(e2, ncells(e1)) ) ) )
+	}
+)	
+
+setMethod("Compare", signature(e1='numeric', e2='RasterLayer'),
+	function(e1,e2){
+		if (!is.atomic(e1)) {
+			stop('first argument should be atomic (a single number)')
+		}
+		return(setRaster(e2, values=callGeneric(.getRasterValues(e2), rep(e1, ncells(e2)) ) ) )
+	}
+)	
+
+
+
 setMethod("Compare", signature(e1='RasterLayer', e2='RasterLayer'),
 	function(e1,e2){
 		cond <- compare(c(e1, e2), bb=TRUE, rowcol=TRUE, prj=TRUE, tolerance=0.0001, stopiffalse=FALSE) 
@@ -33,7 +53,6 @@
 
 
 
-
 .getRasterValues <- function(x) {
 # need to take care of 'spase'
 	if (dataContent(x) != 'all') {



More information about the Raster-commits mailing list