你在设置
x
和
y
在里面
overlay()
但是使用
data
,
mn
,
z
和
sd
作为参数。使用:
z <- raster::clusterR(x = data, fun = function(data, mn){ raster::overlay(x = data, y = mn, fun = function(x, y){ x - y }, na.rm = na.rm }, export = mn)
z <- raster::clusterR(x = data, fun = function(z, sd){ raster::overlay(x = z, y = sd, fun = function(x, y){ x / y }, na.rm = na.rm) }, export = sd)
提议
:(始终提供示例数据)
library(raster)
set.seed(123)
r <- raster()
r[] <- 1:ncell(r)
data <- r
mn <- setValues(r , rnorm(ncell(r)))
data[1:1000] <- NA # to force some NA testing
sd <- r*2
fun1 <- function(x,y){x - y}
fun2 <- function(x,y){x / y}
beginCluster()
z <- clusterR(stack(data,mn), overlay, arg = list(fun = fun1))
z <- clusterR(stack(z,sd), overlay, arg = list(fun = fun2))
endCluster()
plot(z)