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

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


Author: rhijmans
Date: 2009-01-13 13:19:52 +0100 (Tue, 13 Jan 2009)
New Revision: 133

Modified:
   pkg/raster/R/group.generic.functions.R
   pkg/raster/R/set.values.R
Log:


Modified: pkg/raster/R/group.generic.functions.R
===================================================================
--- pkg/raster/R/group.generic.functions.R	2009-01-13 12:09:13 UTC (rev 132)
+++ pkg/raster/R/group.generic.functions.R	2009-01-13 12:19:52 UTC (rev 133)
@@ -23,8 +23,8 @@
 
 setMethod("Compare", signature(e1='RasterLayer', e2='numeric'),
 	function(e1,e2){
-		if (!is.atomic(e2)) {
-			stop('second argument should be atomic (a single number)')
+		if (!isTRUE(is.atomic(e2) & length(e2)==1)) {
+			stop('second argument should be a single number')
 		}
 		return(setRaster(e1, values=callGeneric(.getRasterValues(e1), rep(e2, ncells(e1)) ) ) )
 	}
@@ -32,20 +32,18 @@
 
 setMethod("Compare", signature(e1='numeric', e2='RasterLayer'),
 	function(e1,e2){
-		if (!is.atomic(e1)) {
-			stop('first argument should be atomic (a single number)')
+		if (!isTRUE(is.atomic(e2) & length(e2)==1)) {
+			stop('first argument should be 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) 
 		if (!cond) {
-			stop("Cannot compare RasterLayers that have different BasicRaster attributes. See 'as(e1, 'BasicRaster')==as(e2, 'BasicRaster')")
+			stop("Cannot compare RasterLayers that have different BasicRaster attributes. See compare()")
 		}	
 		return(setRaster(e1, values=callGeneric(.getRasterValues(e1), .getRasterValues(e2) ) ) )
 	}

Modified: pkg/raster/R/set.values.R
===================================================================
--- pkg/raster/R/set.values.R	2009-01-13 12:09:13 UTC (rev 132)
+++ pkg/raster/R/set.values.R	2009-01-13 12:19:52 UTC (rev 133)
@@ -6,6 +6,11 @@
 
 
 
+#if (!isGeneric("setValues")) {
+#	setGeneric("setValues", function(object, values, rownr)
+#		standardGeneric("xyValues"))   }	
+
+	
 setValues <- function(raster, values, rownr=-1) {
 	if (!is.vector(values)) {stop('values must be a vector')}
 	if (length(values) == 0) {	stop('length(values==0). If this is intended then use clearValues(raster)') }



More information about the Raster-commits mailing list