[Raster-commits] r333 - pkg/raster/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Mar 9 06:55:04 CET 2009
Author: rhijmans
Date: 2009-03-09 06:55:04 +0100 (Mon, 09 Mar 2009)
New Revision: 333
Modified:
pkg/raster/R/overlay.R
Log:
Modified: pkg/raster/R/overlay.R
===================================================================
--- pkg/raster/R/overlay.R 2009-03-09 05:46:00 UTC (rev 332)
+++ pkg/raster/R/overlay.R 2009-03-09 05:55:04 UTC (rev 333)
@@ -8,7 +8,9 @@
setMethod('overlay', signature(x='RasterLayer', y='missing'),
function(x, y, fun=sum, filename="", overwrite=FALSE, filetype='raster', datatype='FLT4S', track=-1){
+
return(calc(x, fun=fun, filename=filename, overwrite=overwrite, filetype=filetype, datatype=datatype, track=track))
+
}
)
@@ -34,11 +36,6 @@
setMethod('overlay', signature(x='list', y='missing'),
function(x, y, fun=sum, filename="", overwrite=FALSE, filetype='raster', datatype='FLT4S', track=-1){
- 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 }
- if (missing(datatype)) {datatype='FLT4S'}
- if (missing(track)) {track=-1}
compare(x)
@@ -73,8 +70,8 @@
outraster <- setFilename(outraster, filename )
} else {
v <- vector(length=ncell(outraster))
- endcell <- 0
- inccol <- ncol(outraster) - 1
+ startcells <- cellFromCol(outraster, 1)
+ endcells <- cellFromCol(outraster, ncol(outraster))
}
}
starttime <- proc.time()
@@ -96,9 +93,7 @@
if (filename(outraster) == "") {
# v <- c(v, vals)
- startcell <- endcell + 1
- endcell <- startcell + inccol
- v[startcell:endcell] <- vals
+ v[startcells[r]:endcells[r]] <- vals
} else {
outraster <- setValues(outraster, vals, r)
outraster <- writeRaster(outraster, filetype=filetype, overwrite=overwrite)
@@ -112,7 +107,5 @@
}
}
return(outraster)
-
-
}
)
More information about the Raster-commits
mailing list