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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jan 27 04:33:00 CET 2009


Author: rhijmans
Date: 2009-01-27 04:33:00 +0100 (Tue, 27 Jan 2009)
New Revision: 187

Added:
   pkg/raster/R/compare.logical.functions.R
Modified:
   pkg/raster/R/Merge.R
   pkg/raster/R/Overlay.R
   pkg/raster/R/aggregate.R
   pkg/raster/R/calc.R
   pkg/raster/R/group.generic.functions.R
   pkg/raster/R/init.R
   pkg/raster/R/neighborhood.R
   pkg/raster/R/reclass.R
   pkg/raster/R/replacement.R
   pkg/raster/R/write.R
   pkg/raster/R/writeGDAL.R
   pkg/raster/man/aggregate.Rd
   pkg/raster/man/calc.Rd
   pkg/raster/man/mCalc.Rd
   pkg/raster/man/overlay.Rd
Log:


Modified: pkg/raster/R/Merge.R
===================================================================
--- pkg/raster/R/Merge.R	2009-01-27 02:29:16 UTC (rev 186)
+++ pkg/raster/R/Merge.R	2009-01-27 03:33:00 UTC (rev 187)
@@ -46,7 +46,15 @@
 	outraster <- setRaster(rasters[[1]], filename)
 #	bndbox <- newBbox(bb[1,1], bb[1,2], bb[2,1], bb[2,2])
 	outraster <- setBbox(outraster, bb, keepres=TRUE, snap=FALSE)
-
+	
+	isint <- TRUE
+	for (i in 1:length(rasters)) {
+		if (rasters[[i]]@file at datatype != 'integer') {
+			isInt <- FALSE
+		}
+	}
+	if (isInt) { outraster <- setDatatype(outraster, 'integer') }
+	
 	rowcol <- matrix(0, ncol=3, nrow=length(rasters))
 	for (i in 1:length(rasters)) {
 		xy1 <- xyFromCell(rasters[[i]], 1) # first row/col on old raster[[i]]

Modified: pkg/raster/R/Overlay.R
===================================================================
--- pkg/raster/R/Overlay.R	2009-01-27 02:29:16 UTC (rev 186)
+++ pkg/raster/R/Overlay.R	2009-01-27 03:33:00 UTC (rev 187)
@@ -11,7 +11,7 @@
 )
 
 
-Overlay <- function(x, y, ..., fun, filename="", overwrite=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 <- "" }
@@ -43,6 +43,7 @@
 	}
 	outraster <- setRaster(x)
 	outraster <- setFilename(outraster, filename)
+	if (asInt) { outraster <- setDatatype(outraster, 'integer') }
 
 	inram <- TRUE
 	ondisk <- TRUE

Modified: pkg/raster/R/aggregate.R
===================================================================
--- pkg/raster/R/aggregate.R	2009-01-27 02:29:16 UTC (rev 186)
+++ pkg/raster/R/aggregate.R	2009-01-27 03:33:00 UTC (rev 187)
@@ -5,7 +5,7 @@
 # Version 0,7
 # Licence GPL v3
 
-Aggregate <- function(raster, fact = 2, fun = mean, expand = TRUE, rm.NA = TRUE, filename="", overwrite=FALSE, ForceIntOutput = FALSE)  {
+Aggregate <- function(raster, 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') }
@@ -34,11 +34,7 @@
 	outraster <- setBbox(outraster, bndbox, keepres=F)
 	outraster <- setRowCol(outraster, nrows=rsteps, ncols=csteps) 
 	
-	if (ForceIntOutput) { 
-		outraster <- setDatatype(outraster, 'integer')
-	} else { 
-		outraster <- setDatatype(outraster, 'numeric') 
-	}
+	if (asInt) { outraster <- setDatatype(outraster, 'integer') }
 	
 	if (dataContent(raster) == 'all') {	
 		cols <- rep(rep(1:csteps, each=xfact)[1:ncol(raster)], times=nrow(raster))

Modified: pkg/raster/R/calc.R
===================================================================
--- pkg/raster/R/calc.R	2009-01-27 02:29:16 UTC (rev 186)
+++ pkg/raster/R/calc.R	2009-01-27 03:33:00 UTC (rev 187)
@@ -5,13 +5,13 @@
 # Licence GPL v3
 
 
-calc <- function(raster, fun=sqrt, filename="", overwrite=FALSE, ForceIntOutput=FALSE) {
+calc <- function(raster, fun=sqrt, filename="", overwrite=FALSE, asInt=FALSE) {
 	if (length(fun(5)) > 1) { 
 		stop("function 'fun' returns more than one value") 
 	}
 	filename <- trim(filename)
 	outraster <- setRaster(raster, filename)
-	if (ForceIntOutput) {setDatatype(outraster, 'integer')}
+	if (asInt) {setDatatype(outraster, 'integer')}
 	
 	if (!(dataContent(raster) == 'all' | dataContent(raster) == 'sparse' | dataSource(raster) == 'disk')) {
 		stop('raster has no data on disk, nor a complete set of raster values in memory')
@@ -43,7 +43,7 @@
 
 
 
-mCalc <- function(object, fun=sum, filename="", overwrite=FALSE, ForceIntOutput=FALSE) {
+mCalc <- function(object, fun=sum, filename="", overwrite=FALSE, asInt=FALSE) {
 	if (length(fun(seq(1:5))) > 1) { 
 		stop("function 'fun' returns more than one value") 
 	}
@@ -53,7 +53,7 @@
 		object <- readAll(object)
 		outraster <- setValues(outraster, apply(values(object), 1, fun)) 
 	} else {
-		if (ForceIntOutput) { 
+		if (asInt) { 
 			outraster <- setDatatype(outraster, "integer") 
 		}
 		for (r in 1:nrow(object)) {

Added: pkg/raster/R/compare.logical.functions.R
===================================================================
--- pkg/raster/R/compare.logical.functions.R	                        (rev 0)
+++ pkg/raster/R/compare.logical.functions.R	2009-01-27 03:33:00 UTC (rev 187)
@@ -0,0 +1,165 @@
+# Authors: Robert J. Hijmans, r.hijmans at gmail.com 
+# International Rice Research Institute
+# Date :  January 2009
+# Version 0.8
+# Licence GPL v3
+
+
+.getLogicalRowValues <- function(x, r) {
+# need to take care of 'spase'
+	v <- .getRowValues(x, r)
+	v[v<0] <- 0
+	v[v>0] <- 1
+	return(v)
+}	
+
+
+.getLogicalValues <- function(x) {
+	v <- .getRasterValues(x)
+	v[v<0] <- 0
+	v[v>0] <- 1
+	return(v)
+}
+
+
+setMethod('==', signature(e1='BasicRaster', e2='BasicRaster'),
+	function(e1,e2){
+		cond <- compare(c(e1, e2), bb=TRUE, rowcol=TRUE, prj=TRUE, tolerance=0.0001, stopiffalse=FALSE) 
+		return(cond)
+	}
+)	
+
+
+
+setMethod('!=', signature(e1='BasicRaster', e2='BasicRaster'),
+	function(e1,e2){
+		cond <- compare(c(e1, e2), bb=TRUE, rowcol=TRUE, prj=TRUE, tolerance=0.0001, stopiffalse=FALSE) 
+		return(!cond)
+	}
+)	
+
+
+setMethod("Compare", signature(e1='RasterLayer', e2='numeric'),
+	function(e1,e2){
+		if (!isTRUE(is.atomic(e2) & length(e2)==1)) {
+			stop('second argument should be a single number')
+		}
+		if (.CanProcessInMemory(e1, 2)) {
+			raster <- setRaster(e1)
+			raster <- setDatatype(raster, datatype='integer', datasize=2)
+			raster <- setValues(raster, values=callGeneric(.getRasterValues(e1), rep(e2, ncell(e1)) ) )			
+		} else {
+			raster <- setRaster(e1, filename=tempfile())
+			raster <- setDatatype(raster, datatype='integer', datasize=2)
+			rowrep <- rep(e2, ncol(e1))
+			for (r in 1:nrow(e1)) {
+				raster <- setValues(raster, callGeneric( .getRowValues(e1, r), rowrep ), r)
+				raster <- writeRaster(raster)
+			}
+		}
+		return(raster)
+	}
+)	
+
+setMethod("Compare", signature(e1='numeric', e2='RasterLayer'),
+	function(e1,e2){
+		if (!isTRUE(is.atomic(e2) & length(e2)==1)) {
+			stop('first argument should be a single number')
+		}
+		if (.CanProcessInMemory(e2, 2)) {
+			raster <- setRaster(e2)
+			raster <- setDatatype(raster, datatype='integer', datasize=2)
+			raster <- setValues(raster, callGeneric(.getRasterValues(e2), rep(e1, ncell(e2)) ) )
+		} else {
+			raster <- setRaster(e2, filename=tempfile())
+			raster <- setDatatype(raster, datatype='integer', datasize=2)
+			rowrep <- rep(e1, ncol(e2))
+			for (r in 1:nrow(e2)) {
+				raster <- setValues(raster, callGeneric( .getRowValues(e2, r), rowrep ), r)
+				raster <- writeRaster(raster)
+			}
+		}
+		return(raster)
+	}
+)	
+
+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 compare()")
+		}	
+		if (.CanProcessInMemory(e1, 2)) {
+			raster <- setRaster(e1) 
+			raster <- setDatatype(raster, datatype='integer', datasize=2)
+			raster <- setValues(raster, callGeneric(.getRasterValues(e1), .getRasterValues(e2) ) ) 
+		} else {
+			raster <- setRaster(e1, filename=tempfile())
+			raster <- setDatatype(raster, datatype='integer', datasize=2)
+			for (r in 1:nrow(e1)) {
+				raster <- setValues(raster, callGeneric( .getRowValues(e1, r), .getRowValues(e2, r) ), r)
+				raster <- writeRaster(raster)
+			}
+		}
+		return(raster)
+	}
+)	
+
+
+
+
+
+setMethod("Logic", signature(e1='RasterLayer', e2='RasterLayer'),
+    function(e1, e2){ 
+		if ( compare(c(e1, e2)) ) {
+			if (.CanProcessInMemory(e1, 2)) {
+				raster <- setRaster(e1)
+				raster <- setDatatype(raster, datatype='integer', datasize=2)
+				raster <- setValues(raster, callGeneric(.getLogicalValues(e1), .getLogicalValues(e2)))
+			} else {
+				raster <- setRaster(e1, filename=tempfile())
+				raster <- setDatatype(raster, datatype='integer', datasize=2)	
+				for (r in 1:nrow(e1)) {
+					raster <- setValues(raster, callGeneric( .getLogicalRowValues(e1, r), .getLogicalRowValues(e2, r) ), r)
+					raster <- writeRaster(raster)
+				}
+			}	
+			return(raster)
+		}	
+	}
+)
+
+
+
+setMethod("is.na", signature(x='RasterLayer'),
+	function(x) {
+		raster <- setRaster(x)
+		raster <- setDatatype(raster, datatype='integer', datasize=2)
+		return(setValues(raster, is.na(.getRasterValues(x))))
+	}
+)	
+
+setMethod("is.nan", signature(x='RasterLayer'),
+	function(x) {
+		raster <- setRaster(x)
+		raster <- setDatatype(raster, datatype='integer', datasize=2)
+		return(setValues(raster, is.nan(.getRasterValues(x))))
+	}
+)	
+
+setMethod("is.infinite", signature(x='RasterLayer'),
+	function(x) {
+		raster <- setRaster(x)
+		raster <- setDatatype(raster, datatype='integer', datasize=2)
+		return(setValues(raster, values=is.infinite(.getRasterValues(x))))
+	}
+)	
+
+setMethod("is.finite", signature(x='RasterLayer'),
+	function(x) {
+		raster <- setRaster(x)
+		raster <- setDatatype(raster, datatype='integer', datasize=2)
+		return(setValues(raster, values=is.finite(.getRasterValues(x))))
+	}
+)	
+

Modified: pkg/raster/R/group.generic.functions.R
===================================================================
--- pkg/raster/R/group.generic.functions.R	2009-01-27 02:29:16 UTC (rev 186)
+++ pkg/raster/R/group.generic.functions.R	2009-01-27 03:33:00 UTC (rev 187)
@@ -1,14 +1,10 @@
-# Authors: Robert J. Hijmans, r.hijmans at gmail.com and Jacob van Etten
+# Authors: Robert J. Hijmans, r.hijmans at gmail.com 
 # International Rice Research Institute
 # Date :  January 2009
-# Version 0,8
+# Version 0.8
 # Licence GPL v3
 
 
-# for very large rasters, use 
-#  filename <- tempfile() 
-
-
 .CanProcessInMemory <- function(raster, n=2, datasize=16) {
 #	memalloc <- n * ncell(raster) * 8
 #	memavailable <- memory.limit()-memory.size()
@@ -50,22 +46,6 @@
 }	
 
 
-.getLogicalRowValues <- function(x, r) {
-# need to take care of 'spase'
-	v <- .getRowValues(x, r)
-	v[v<0] <- 0
-	v[v>0] <- 1
-	return(v)
-}	
-
-
-.getLogicalValues <- function(x) {
-	v <- .getRasterValues(x)
-	v[v<0] <- 0
-	v[v>0] <- 1
-	return(v)
-}
-
 .getAllTypeOfValues <- function(x, y, i) {
 	if ( extends(class(y), "Raster") & compare(c(x, y)) ) {			
 		return(.getRasterValues(y))
@@ -79,100 +59,8 @@
 }
 
 
-setMethod('==', signature(e1='BasicRaster', e2='BasicRaster'),
-	function(e1,e2){
-		cond <- compare(c(e1, e2), bb=TRUE, rowcol=TRUE, prj=TRUE, tolerance=0.0001, stopiffalse=FALSE) 
-		return(cond)
-	}
-)	
 
 
-
-setMethod('!=', signature(e1='BasicRaster', e2='BasicRaster'),
-	function(e1,e2){
-		cond <- compare(c(e1, e2), bb=TRUE, rowcol=TRUE, prj=TRUE, tolerance=0.0001, stopiffalse=FALSE) 
-		return(!cond)
-	}
-)	
-
-
-setMethod("Compare", signature(e1='RasterLayer', e2='numeric'),
-	function(e1,e2){
-		if (!isTRUE(is.atomic(e2) & length(e2)==1)) {
-			stop('second argument should be a single number')
-		}
-		if (.CanProcessInMemory(e1, 2)) {
-			raster <- setRaster(e1, values=callGeneric(.getRasterValues(e1), rep(e2, ncell(e1)) ) )
-			raster <- setDatatype(raster, datatype='integer', datasize=2)
-		} else {
-			raster <- setRaster(e1, filename=tempfile())
-			rowrep <- rep(e2, ncol(e1))
-			for (r in 1:nrow(e1)) {
-				raster <- setValues(raster, callGeneric( .getRowValues(e1, r), rowrep ), r)
-				raster <- writeRaster(raster)
-			}
-			raster <- setDatatype(raster, datatype='integer', datasize=2)
-		}
-		return(raster)
-	}
-)	
-
-setMethod("Compare", signature(e1='numeric', e2='RasterLayer'),
-	function(e1,e2){
-		if (!isTRUE(is.atomic(e2) & length(e2)==1)) {
-			stop('first argument should be a single number')
-		}
-		if (.CanProcessInMemory(e2, 2)) {
-			raster <- setRaster(e2, values=callGeneric(.getRasterValues(e2), rep(e1, ncell(e2)) ) )
-			raster <- setDatatype(raster, datatype='integer', datasize=2)
-		} else {
-			raster <- setRaster(e2, filename=tempfile())
-			rowrep <- rep(e1, ncol(e2))
-			for (r in 1:nrow(e2)) {
-				raster <- setValues(raster, callGeneric( .getRowValues(e2, r), rowrep ), r)
-				raster <- writeRaster(raster)
-			}
-			raster <- setDatatype(raster, datatype='integer', datasize=2)
-		}
-		return(raster)
-	}
-)	
-
-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 compare()")
-		}	
-		if (.CanProcessInMemory(e1, 2)) {
-			raster <- setRaster(e1, values=callGeneric(.getRasterValues(e1), .getRasterValues(e2) ) ) 
-			raster <- setDatatype(raster, datatype='integer', datasize=2)
-		} else {
-			raster <- setRaster(e1, filename=tempfile())
-			for (r in 1:nrow(e1)) {
-				raster <- setValues(raster, callGeneric( .getRowValues(e1, r), .getRowValues(e2, r) ), r)
-				raster <- writeRaster(raster)
-			}
-			raster <- setDatatype(raster, datatype='integer', datasize=2)
-		}
-		return(raster)
-	}
-)	
-
-
-
-setMethod("[", "RasterLayer",
-	function(x, i, j, ..., drop = TRUE) {
-		if (!missing(drop)) { stop("drop is ignored. It is always set to FALSE") }
-		if (!missing(j)) { stop("can only set values with a single index (a vector)") }
-		if (missing(i)) { return(x) }
-		v <- values(i)
-		v[x] <- i
-		return(setRaster(x, v))
-	}
-)
-
-
 setMethod("Math", signature(x='RasterLayer'),
     function(x){ 
 		if (.CanProcessInMemory(x, 1)) {
@@ -190,24 +78,6 @@
 
 
 
-setMethod("Logic", signature(e1='RasterLayer', e2='RasterLayer'),
-    function(e1, e2){ 
-		if ( compare(c(e1, e2)) ) {
-			if (.CanProcessInMemory(e1, 2)) {
-				raster <- setRaster(e1, values=callGeneric(.getLogicalValues(e1), .getLogicalValues(e2)))
-			} else {
-				raster <- setRaster(e1, filename=tempfile())
-				for (r in 1:nrow(e1)) {
-					raster <- setValues(raster, callGeneric( .getLogicalRowValues(e1, r), .getLogicalRowValues(e2, r) ), r)
-					raster <- writeRaster(raster)
-				}
-			}	
-			return(raster)
-		}	
-	}
-)
-
-
 	
 setMethod("Arith", signature(e1='RasterLayer', e2='RasterLayer'),
     function(e1, e2){ 
@@ -320,27 +190,4 @@
 	}
 )	
 
-setMethod("is.na", signature(x='RasterLayer'),
-	function(x) {
-		return(setRaster(x, values=is.na(.getRasterValues(x))))
-	}
-)	
 
-setMethod("is.nan", signature(x='RasterLayer'),
-	function(x) {
-		return(setRaster(x, values=is.nan(.getRasterValues(x))))
-	}
-)	
-
-setMethod("is.infinite", signature(x='RasterLayer'),
-	function(x) {
-		return(setRaster(x, values=is.infinite(.getRasterValues(x))))
-	}
-)	
-
-setMethod("is.finite", signature(x='RasterLayer'),
-	function(x) {
-		return(setRaster(x, values=is.finite(.getRasterValues(x))))
-	}
-)	
-

Modified: pkg/raster/R/init.R
===================================================================
--- pkg/raster/R/init.R	2009-01-27 02:29:16 UTC (rev 186)
+++ pkg/raster/R/init.R	2009-01-27 03:33:00 UTC (rev 187)
@@ -5,10 +5,10 @@
 # Licence GPL v3
 
 
-init <- function(raster, fun=runif, filename="", overwrite=FALSE, ForceIntOutput=FALSE) {
+init <- function(raster, fun=runif, filename="", overwrite=FALSE, asInt=FALSE) {
 	filename <- trim(filename)
 	outraster <- setRaster(raster, filename)
-	if (ForceIntOutput) {setDatatype(outraster, 'integer') }
+	if (asInt) {setDatatype(outraster, 'integer') }
 
 	if ( dataContent(raster) == 'all' | dataSource(raster) == 'ram' ) {
 		n <- ncell(raster)
@@ -37,14 +37,14 @@
 }
 
 
-isNA <- function(raster, value=0, filename="", overwrite=FALSE, ForceIntOutput=FALSE) {
+isNA <- function(raster, value=0, filename="", overwrite=FALSE, asInt=FALSE) {
 	fun <- function(x) { x[is.na(x)] <- value; return(x)} 
-	raster <- calc(raster, fun, filename, overwrite=overwrite, ForceIntOutput=ForceIntOutput)
+	raster <- calc(raster, fun, filename, overwrite=overwrite, asInt=asInt)
 	return(raster) 
 }
 
 	
-setNA <- function(raster, operator= "<=", value=0, filename="", overwrite=FALSE, ForceIntOutput=FALSE) {
+setNA <- function(raster, operator= "<=", value=0, filename="", overwrite=FALSE, asInt=FALSE) {
 	if (operator == ">") { fun <- function(x) { x[x>value] <- NA; return(x)}
 	} else if (operator == "<") { fun <- function(x) { x[x<value] <- NA; return(x)}
 	} else if (operator == "<=") { fun <- function(x) { x[x<=value] <- NA; return(x)}
@@ -52,7 +52,7 @@
 	} else if (operator == "==") { fun <- function(x) { x[x==value] <- NA; return(x)}
 	} else if (operator == "!=") { fun <- function(x) { x[x!=value] <- NA; return(x)}
 	}
-	return(calc(raster, fun, filename, overwrite=overwrite, ForceIntOutput=ForceIntOutput))
+	return(calc(raster, fun, filename, overwrite=overwrite, asInt=asInt))
 }
 
 

Modified: pkg/raster/R/neighborhood.R
===================================================================
--- pkg/raster/R/neighborhood.R	2009-01-27 02:29:16 UTC (rev 186)
+++ pkg/raster/R/neighborhood.R	2009-01-27 03:33:00 UTC (rev 187)
@@ -41,7 +41,7 @@
 }
 	
 
-neighborhood <- function(raster, fun=mean, filename="", ngb=3, keepdata=TRUE, overwrite=FALSE, ForceIntOutput=FALSE) {
+neighborhood <- function(raster, fun=mean, filename="", ngb=3, keepdata=TRUE, overwrite=FALSE, asInt=FALSE) {
 	ngb <- round(ngb)
 	if ((ngb / 2) == floor(ngb/2)) { stop("only odd neighborhoods are supported") }
 	if (ngb == 1) { stop("ngb should be 3 or larger")  } 
@@ -49,7 +49,7 @@
 	
 	filename <- trim(filename)
 	ngbgrid <- setRaster(raster, filename)
-	if (ForceIntOutput) {setDatatype(ngbgrid, 'integer') }
+	if (asInt) {setDatatype(ngbgrid, 'integer') }
 
 # first create an empty matrix with nrows = ngb and ncols = raster at ncols
 	ngbdata1 <- array(data = NA, dim = c(ngb, ncol(raster)))

Modified: pkg/raster/R/reclass.R
===================================================================
--- pkg/raster/R/reclass.R	2009-01-27 02:29:16 UTC (rev 186)
+++ pkg/raster/R/reclass.R	2009-01-27 03:33:00 UTC (rev 187)
@@ -4,7 +4,7 @@
 # Version 0,6
 # Licence GPL v3
 
-reclass <- function(raster, rclmat, filename="", overwrite=FALSE, ForceIntOutput=FALSE)  {
+reclass <- function(raster, rclmat, filename="", overwrite=FALSE, asInt=FALSE)  {
 	if (class(raster) != 'RasterLayer' ) {
 		stop('first two arguments should be objects of class "RasterLayer"')
 	}
@@ -18,7 +18,7 @@
 	print(rclmat)
 	
 	outraster <- setRaster(raster, filename)
-	if (ForceIntOutput) { 
+	if (asInt) { 
 		outraster <- setDatatype(outraster, "integer") 
 		res <- vector(mode = "integer", length = ncol(raster))
 	} else { 

Modified: pkg/raster/R/replacement.R
===================================================================
--- pkg/raster/R/replacement.R	2009-01-27 02:29:16 UTC (rev 186)
+++ pkg/raster/R/replacement.R	2009-01-27 03:33:00 UTC (rev 187)
@@ -28,6 +28,9 @@
 	return(values(r)[cells])
 }
 
+
+
+
 setMethod("[", "RasterLayer",
 	function(x,i,j,...,drop=FALSE) {
 		if (!missing(j)) { stop("incorrect number of dimensions") }

Modified: pkg/raster/R/write.R
===================================================================
--- pkg/raster/R/write.R	2009-01-27 02:29:16 UTC (rev 186)
+++ pkg/raster/R/write.R	2009-01-27 03:33:00 UTC (rev 187)
@@ -46,9 +46,9 @@
 	} else { 
 		.isSupportedGDALFormat(format)
 		if (dataContent(raster) == 'row' ) {
-			raster <- .writeGDALrow(raster, format, overwrite, ForceIntOutput=FALSE, mvFlag=NA, options=NULL)
+			raster <- .writeGDALrow(raster, format, overwrite, asInt=FALSE, mvFlag=NA, options=NULL)
 		} else {
-			raster <- .writeGDALall(raster, format, overwrite, ForceIntOutput=FALSE, mvFlag=NA, options=NULL)
+			raster <- .writeGDALall(raster, format, overwrite, asInt=FALSE, mvFlag=NA, options=NULL)
 		}  
 	}
 	return(raster)

Modified: pkg/raster/R/writeGDAL.R
===================================================================
--- pkg/raster/R/writeGDAL.R	2009-01-27 02:29:16 UTC (rev 186)
+++ pkg/raster/R/writeGDAL.R	2009-01-27 03:33:00 UTC (rev 187)
@@ -11,7 +11,7 @@
 # authors: Timothy H. Keitt, Roger Bivand, Edzer Pebesma, Barry Rowlingson
 
 
-.getGDALtransient <- function(raster, gdalfiletype, overwrite, ForceIntOutput, mvFlag,  options)  {
+.getGDALtransient <- function(raster, gdalfiletype, overwrite, asInt, mvFlag,  options)  {
 #	.isSupportedFormat(gdalfiletype)
 	
 # this is a RasterLayer hence nbands = 1:
@@ -31,7 +31,7 @@
 
 #.GDALDataTypes <- c('Unknown', 'Byte', 'UInt16', 'Int16', 'UInt32','Int32', 'Float32', 'Float64', 'CInt16', 'CInt32',   'CFloat32', 'CFloat64')	
 # this needs to get fancier; depending on object and the abilties of the drivers
-	if (dataType(raster) == 'integer' | ForceIntOutput) {
+	if (dataType(raster) == 'integer' | asInt) {
 		dataformat <- 'Int32'
 		if (raster at data@haveminmax) {
 			if (minValue(raster) > -32768 & maxValue(raster) <= 32767) {
@@ -54,14 +54,14 @@
 }
 
 
-.writeGDALrow <- function(raster, gdalfiletype, overwrite, ForceIntOutput, mvFlag, options ) {
+.writeGDALrow <- function(raster, gdalfiletype, overwrite, asInt, mvFlag, options ) {
 	
 	rownr <- rowFromCell(raster, dataIndices(raster)[1])
 	if (rownr %in%  c(1, 10, 50, 100, 250, 500, 1000, 2500, 5000, 10000, 20000, 30000, 40000, 50000, 100000)) {
 		print( paste("writing row", rownr, "at:", format(Sys.time(), "%H:%M:%S")))
 	}
 	if ( rownr == 1) {
-		transient <- .getGDALtransient(raster, gdalfiletype, overwrite, ForceIntOutput, mvFlag, options)
+		transient <- .getGDALtransient(raster, gdalfiletype, overwrite, asInt, mvFlag, options)
 		attr(raster, "transient") <- transient
 		raster at file@driver <- 'gdal'
 		raster at file@gdalhandle <- list()
@@ -84,14 +84,14 @@
 
 
 # ALTERNATIVE
-#.writeGDALall <- function(raster, gdalfiletype, overwrite, ForceIntOutput, mvFlag, options) {
+#.writeGDALall <- function(raster, gdalfiletype, overwrite, asInt, mvFlag, options) {
 #	spgrid <- asSpGrid(raster)	
 #	writeGDAL(spgrid, filename(raster))
 #}
 
-.writeGDALall <- function(raster, gdalfiletype, overwrite, ForceIntOutput, mvFlag, options) {
+.writeGDALall <- function(raster, gdalfiletype, overwrite, asInt, mvFlag, options) {
 	
-	transient <- .getGDALtransient(raster, gdalfiletype, overwrite, ForceIntOutput, mvFlag, options)
+	transient <- .getGDALtransient(raster, gdalfiletype, overwrite, asInt, mvFlag, options)
     for (band in 1:nlayers(raster)) {
 		x <- putRasterData(transient, t(values(raster, format='matrix')), band, c(0, 0)) 
 	}	

Modified: pkg/raster/man/aggregate.Rd
===================================================================
--- pkg/raster/man/aggregate.Rd	2009-01-27 02:29:16 UTC (rev 186)
+++ pkg/raster/man/aggregate.Rd	2009-01-27 03:33:00 UTC (rev 187)
@@ -7,7 +7,7 @@
 	(Dis)aggregated a raster to create a new raster 
 }
 \usage{
-Aggregate(raster, fact = 2, fun = mean, expand = TRUE, rm.NA = TRUE, filename="", overwrite=FALSE, ForceIntOutput = FALSE) 
+Aggregate(raster, fact = 2, fun = mean, expand = TRUE, rm.NA = TRUE, filename="", overwrite=FALSE, asInt = FALSE) 
 disaggregate(raster, fact=2, filename="", overwrite=FALSE) 
 }
 
@@ -18,7 +18,7 @@
   \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}
-  \item{ForceIntOutput}{logical. If \code{TRUE} the values will be rounded and stored as integer}
+  \item{asInt}{logical. If \code{TRUE} the values will be rounded and stored as integer}
   \item{overwrite}{if TRUE, "filename" will be overwritten if it exists}
 }
 

Modified: pkg/raster/man/calc.Rd
===================================================================
--- pkg/raster/man/calc.Rd	2009-01-27 02:29:16 UTC (rev 186)
+++ pkg/raster/man/calc.Rd	2009-01-27 03:33:00 UTC (rev 187)
@@ -12,12 +12,12 @@
   Calculate values for a new raster, from scratch or based on a single existing raster
 }
 \usage{
-calc(raster, fun=sqrt, filename="", overwrite=FALSE, ForceIntOutput=FALSE)
-isNA(raster, value = 0, filename="", overwrite=FALSE, ForceIntOutput = FALSE)
-setNA(raster, operator = "<=", value = 0, filename="", overwrite=FALSE, ForceIntOutput = FALSE)
-init(raster, fun=runif, filename="", overwrite=FALSE, ForceIntOutput = FALSE) 
-neighborhood(raster, fun=mean, filename="", ngb=3, keepdata=TRUE, overwrite=FALSE, ForceIntOutput=FALSE) 
-reclass(raster, rclmat, filename="", overwrite=FALSE, ForceIntOutput = FALSE)
+calc(raster, fun=sqrt, filename="", overwrite=FALSE, asInt=FALSE)
+isNA(raster, value = 0, filename="", overwrite=FALSE, asInt = FALSE)
+setNA(raster, operator = "<=", value = 0, filename="", overwrite=FALSE, asInt = FALSE)
+init(raster, fun=runif, filename="", overwrite=FALSE, asInt = FALSE) 
+neighborhood(raster, fun=mean, filename="", ngb=3, keepdata=TRUE, overwrite=FALSE, asInt=FALSE) 
+reclass(raster, rclmat, filename="", overwrite=FALSE, asInt = FALSE)
 }
 
 \arguments{
@@ -28,7 +28,7 @@
   \item{rclmat}{Matrix for reclassifcation. (see below)}
   \item{filename}{Output filename for a new raster; if NA the result is not written to a file but returned with the RasterLayer object, in the data slot}
   \item{overwrite}{Logical to indicate whether an existing output file should be overwritten}
-  \item{ForceIntOutput}{logical. If \code{TRUE}, output will be integer values}
+  \item{asInt}{logical. If \code{TRUE}, output will be integer values}
   \item{ngb}{Neighborhood size. Expressed in number of cells in a single direction. I.e. 3 refers to 2 cells at each side of the focal cell. Queen's case, 8 cells in total}
   \item{keepdata}{Logical. If \code{TRUE}, NA will be removed for neighborhood computations. The result will only be NA if all cells are NA}
 }

Modified: pkg/raster/man/mCalc.Rd
===================================================================
--- pkg/raster/man/mCalc.Rd	2009-01-27 02:29:16 UTC (rev 186)
+++ pkg/raster/man/mCalc.Rd	2009-01-27 03:33:00 UTC (rev 187)
@@ -7,7 +7,7 @@
 }
 
 \usage{
-mCalc(object, fun=sum, filename="", overwrite=FALSE, ForceIntOutput=FALSE)
+mCalc(object, fun=sum, filename="", overwrite=FALSE, asInt=FALSE)
 }
 
 \arguments{
@@ -15,7 +15,7 @@
   \item{fun}{ the function to be applied }
   \item{filename}{ output filename for a new raster; if NA the result is not written to a file but returned with the RasterLayer object, in the data slot }
   \item{overwrite}{ logical to indicate whether an existing output file should be overwritten }
-  \item{ForceIntOutput}{ logical. If \code{TRUE}, output will be integer values }
+  \item{asInt}{ logical. If \code{TRUE}, output will be integer values }
 }
 
 \details{

Modified: pkg/raster/man/overlay.Rd
===================================================================
--- pkg/raster/man/overlay.Rd	2009-01-27 02:29:16 UTC (rev 186)
+++ pkg/raster/man/overlay.Rd	2009-01-27 03:33:00 UTC (rev 187)
@@ -8,7 +8,7 @@
 }
 
 \usage{
-	Overlay(x, y, ..., fun, filename="", overwrite=FALSE) 
+	Overlay(x, y, ..., fun, filename="", overwrite=FALSE, asInt=FALSE) 
 }
 
 \arguments{
@@ -18,6 +18,7 @@
   \item{fun}{ the function to be appliepd. This should be a function that takes two numbers as an argument }
   \item{filename}{ filename for the output raster. A valid filename must be provided when the data of the input rasters are on disk }
   \item{overwrite}{logical. If \code{TRUE}, existing files will be overwritten}
+  \item{asInt}{logical. If \code{TRUE} the values will be rounded and stored as integer}
 }
 
 \details{



More information about the Raster-commits mailing list