Skip to content
Prev 22441 / 29559 Next

parallel raster processing with calc and mc2d monte carlo simulation

The below works for me. You used function 'f' to clusterR, where it
should have been  'calc'

library(raster)
library(snow)
library(mc2d)

f <- function(x) {
  dBC_BA <- mcdata(x[1], type="0")
  dBC_BA_SE <- mcdata(x[2], type = "0")
  SlopePer <-x[3]
  stBA <- mcstoc(rnorm, type = "U", rtrunc = TRUE, mean = dBC_BA, sd =
dBC_BA_SE, linf = 0, lhs = FALSE)
  BC_AGWBC <- 0.6419 + 0.9307*stBA + (-0.0176)*SlopePer
  AGWBC <- (0.2626263 * BC_AGWBC + 1)^(1/0.2626263)-1
  quantile(AGWBC[], c(0.025, 0.5, 0.975), na.rm=TRUE)
}


b <- brick(system.file("external/rlogo.grd", package="raster"))
x <- calc(b, f)

# new function for cluster. You could also rewrite f to include calc
ff <- function(x) calc(x, f)

beginCluster()
y <- clusterR(b, fun=ff, export='f')
endCluster()

On Tue, Mar 17, 2015 at 9:21 AM, Sean Kearney
<sean.kearney at alumni.ubc.ca> wrote: