[R-sig-Geo] Parallel processing a list of SpatialPoints

Hodgess, Erin HodgessE at uhd.edu
Thu Aug 18 00:11:31 CEST 2016


Do you know Mpi, by any chance,  please?  What kind of machine/operating system are you using,  please? 

Thanks,  
Erin 

Erin M. Hodgess
Associate Professor
Department of Mathematics and Statistics
University of Houston - Downtown
mailto: hodgesse at uhd.edu

________________________________________
From: R-sig-Geo [r-sig-geo-bounces at r-project.org] on behalf of David Wang [dw2116 at outlook.com]
Sent: Wednesday, August 17, 2016 5:00 PM
To: r-sig-geo
Subject: [R-sig-Geo] Parallel processing a list of SpatialPoints

Hello,


I have a list of SpatialPointsDataFrame objects that represent feature centers along the time axis. For example, let's say the list is centers. centers[[1]] are the points at t = 1, centers[[2]] are the points at t = 2, and so on. Now for every point at t, I need to link it to, if any, the nearest point within a search radius at the next time step t + 1. The procedure is applied to all time steps, and the result are tracks that connect selected feature centers in time. I have implemented a solution using igraph package, with every center represented by a vertex and every link by an edge. This way, tracks are simply connected components of the graph. Now because the number of centers and links are quite large, the algorithm takes a while to run. But since finding the nearest neighbors between t and t + 1 and between t + 1 and t + 2 are independent, I think parallel processing should be possible, although I haven't figured out how. Does anyone here happen to have a pointer or !
 two? I work on a multicore PC. Here is my code snippet:


g <- graph.empty(directed = TRUE)
for (k in seq_along(centers)) {
  pts <- centers[[k]]
  g <- add_vertices(g, nv = length(pts), id = k, attr = as.data.frame(pts))
  if (length(V(g)[id == (k - 1)]) > 0 & length(V(g)[id == k]) > 0) {
    v1 <- V(g)[id == (k - 1)]
    v2 <- V(g)[id == k]
    rd <- rdist(cbind(v1$x, v1$y), cbind(v2$x, v2$y))
    for (i in 1:nrow(rd)) {
      if (min(rd[i, ]) < maxDist) {
        e <- c(V(g)[id == (k - 1)][i], V(g)[id == k][which.min(rd[i, ])])
        g <- add_edges(g, e)
      }
    }
  }
}
tracks <- groups(components(g)) # vertex ids along each track


Thanks,

David

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list