[R-sig-Geo] clusterR: error when using a cluster object passed as an argument to function
Guillaume Drolet
droletguillaume at gmail.com
Fri Nov 29 01:34:14 CET 2013
Hi,
I have a function, say fun1, in which I create a SNOW cluster object using:
beginCluster(nodes)
cl <- getCluster()
Then I export variables to the cores (nodes) and load some libraries:
clusterExport(cl, c("tmpdir", "maxmemory", "chunksize"))
clusterEvalQ(cl, c(library(raster), library(rgdal), rasterOptions(tmpdir =
tmpdir, maxmemory = maxmemory, chunksize = chunksize)))
Later in my function, I call a bunch of other functions to which I pass cl
as one of their arguments.
For exemple, say I have fun2 to which I pass cl which in turn is used in a
call to clusterR:
fun2 <- function(x, b, prl, cl) {
if (prl & !inMemory(x)) {
f1 <- function(x, y) {
min(x != y - 1)
}
nm <- clusterR(x, fun = f1, args = list(b), cl = cl)
} else {
nm <- min(x != b - 1)
}
return(nm)
}
When I run fun1 and it gets to the first function which uses cl (fun2 in
this example), this results in the error:
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘writeStart’ for signature
‘"RasterLayer", "SOCKcluster"’
At the moment I don't have a clue about the source of the problem. Only
thing I know is that it used to work when I was running fun1 line by line
and not by calling the function. Thanks for your help!
--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/clusterR-error-when-using-a-cluster-object-passed-as-an-argument-to-function-tp7585230.html
Sent from the R-sig-geo mailing list archive at Nabble.com.
More information about the R-sig-Geo
mailing list