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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Feb 23 02:38:13 CET 2009


Author: rhijmans
Date: 2009-02-23 02:38:12 +0100 (Mon, 23 Feb 2009)
New Revision: 294

Modified:
   pkg/raster/R/compare.logical.functions.R
   pkg/raster/R/group.generic.functions.R
Log:


Modified: pkg/raster/R/compare.logical.functions.R
===================================================================
--- pkg/raster/R/compare.logical.functions.R	2009-02-22 13:53:45 UTC (rev 293)
+++ pkg/raster/R/compare.logical.functions.R	2009-02-23 01:38:12 UTC (rev 294)
@@ -41,6 +41,25 @@
 )	
 
 
+
+setMethod('!', signature(x='RasterLayer'),
+	function(x){
+		if (.CanProcessInMemory(x, 1)) {
+			return(setValues(x, !values(x)))
+		} else {
+			raster <- setRaster(x, filename=tempfile())
+			raster <- setDatatype(raster, 'LOGICAL')
+			for (r in 1:nrow(x)) {
+				raster <- setValues(raster, !.getRowValues(x, r), r)
+				raster <- writeRaster(raster)
+			}
+			return(raster)		
+		}
+	}
+)	
+
+
+
 setMethod("Compare", signature(e1='RasterLayer', e2='numeric'),
 	function(e1,e2){
 		if (!isTRUE(is.atomic(e2) & length(e2)==1)) {
@@ -65,26 +84,9 @@
 
 
 
-setMethod('!', signature(x='RasterLayer'),
-	function(x){
-		if (.CanProcessInMemory(x, 1)) {
-			return(setValues(x, !values(x)))
-		} else {
-			raster <- setRaster(x, filename=tempfile())
-			raster <- setDatatype(raster, 'LOGICAL')
-			for (r in 1:nrow(x)) {
-				raster <- setValues(raster, !.getRowValues(x, r), r)
-				raster <- writeRaster(raster)
-			}
-			return(raster)		
-		}
-	}
-)	
-
-
 setMethod("Compare", signature(e1='numeric', e2='RasterLayer'),
 	function(e1,e2){
-		if (!isTRUE(is.atomic(e2) & length(e2)==1)) {
+		if (!isTRUE(is.atomic(e1) & length(e1)==1)) {
 			stop('first argument should be a single number')
 		}
 		if (.CanProcessInMemory(e2, 2)) {

Modified: pkg/raster/R/group.generic.functions.R
===================================================================
--- pkg/raster/R/group.generic.functions.R	2009-02-22 13:53:45 UTC (rev 293)
+++ pkg/raster/R/group.generic.functions.R	2009-02-23 01:38:12 UTC (rev 294)
@@ -103,11 +103,11 @@
 setMethod("Arith", signature(e1='numeric', e2='RasterLayer'),
     function(e1, e2){ 
 		if (.CanProcessInMemory(e2, 2)) {
-			return(setRaster(e2, values=callGeneric(.getRasterValues(e2), e1)))
+			return(setRaster(e2, values=callGeneric(e1, .getRasterValues(e2))))
 		} else {
 			raster <- setRaster(e2, filename=tempfile())
 			for (r in 1:nrow(e2)) {
-				raster <- setValues(raster, callGeneric( .getRowValues(e2, r), e1) , r)
+				raster <- setValues(raster, callGeneric(e1, .getRowValues(e2, r)) , r)
 				raster <- writeRaster(raster)
 			}
 			return(raster)



More information about the Raster-commits mailing list