[R-sig-Geo] parallelize distance matrix
Ariel Fuentesdi
@riel@fuente@di @ending from u@@ch@cl
Tue Aug 21 20:15:08 CEST 2018
Hi, I want to parallelize the calculation of a distance matrix, I've tried
but I wasn't succesful, this is what I did with a training data.
My data set is:
ll <- matrix(c(5, 6, 60, 60), ncol=2)
And I use the function *spDistsN1* from the library *"sp"* to obtain a
distance matrix with *apply*:
apply(ll, 1, function(x) spDistsN1(as.matrix(ll), x, longlat = T))
But I want to do it with parallelization, so for that:
library(parallel)
ncore <- detectCores()
cl <- makeCluster(ncore)
clusterEvalQ(cl = cl, expr = c(library(sp)))
parRapply(cl = cl, x = ll, FUN = function(x) spDistsN1(as.matrix(ll), x,
longlat = T))
It shows the following error:
*Error in checkForRemoteErrors(val) : 4 nodes produced errors; first error:
object 'll' not found*
How do I fix it?
Regards,
Ariel Fuentes
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list