[Raster-commits] r156 - pkg/raster/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Jan 19 10:33:28 CET 2009
Author: rhijmans
Date: 2009-01-19 10:33:28 +0100 (Mon, 19 Jan 2009)
New Revision: 156
Modified:
pkg/raster/R/Overlay.R
Log:
Modified: pkg/raster/R/Overlay.R
===================================================================
--- pkg/raster/R/Overlay.R 2009-01-19 01:20:29 UTC (rev 155)
+++ pkg/raster/R/Overlay.R 2009-01-19 09:33:28 UTC (rev 156)
@@ -23,11 +23,19 @@
for (i in 1:length(obs)) {
if (extends(class(obs[[i]]), "RasterLayer")) {
rasters <- c(rasters, obs[[i]])
- }
+ } else {
+ stop("only RasterLayer objects allowed as ... arguments.")
+ }
}
}
if (length(rasters) > 6) {stop("sorry, this function cannot take more than 6 RasterLayers at a time")}
+ f <- formals(fun)
+ if (length(f) != length(rasters)) {
+ stop(paste("Function/data mismatch. You provided a function with", length(f), "arguments. While passing", length(rasters), "RasterLayer objects."))
+ }
+
+
for (i in 2:length(rasters)) {
if (!compare(c(x, rasters[i]))) {
stop('Extent and/or resolution of rasters do not match')
@@ -43,9 +51,11 @@
if (dataSource(rasters[[i]]) != 'disk') {ondisk <- FALSE}
}
-
+
if ( inram ) {
# there has to be a smarter way then this!
+ # perhaps via as.function(alist( )) ??
+
if (length(rasters) == 2) {
vals <- fun( values(rasters[[1]]), values(rasters[[2]]) )
} else if (length(rasters) == 3) {
More information about the Raster-commits
mailing list