[R-sig-Geo] parallelize distance matrix

Roman Luštrik rom@n@lu@trik @ending from gm@il@com
Tue Aug 21 20:53:32 CEST 2018


Cross posted on SO:
https://stackoverflow.com/questions/51952776/parallelization-apply-to-parrapply

On Tue, Aug 21, 2018 at 8:15 PM Ariel Fuentesdi <ariel.fuentesdi using usach.cl>
wrote:

> 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]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>


-- 
In God we trust, all others bring data.

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list