Skip to content
Prev 24089 / 29559 Next

igraph and spatial

Hi,

Recently, I used igraph with spatial objects.

Once you have the coordinates of the nodes composing an edge, you can
transform it into a spatiallines object with this function :

makeLineFromCoords <- function(coords, i) {
  Sl1 = Line(coords)
  S1 = Lines(list(Sl1), ID=as.character(i))
  Sl = SpatialLines(list(S1))
  return(Sl)
}

For all the routing stuff within R, this resource by B. Rowlingson is quite
inspiring :
http://rstudio-pubs-static.s3.amazonaws.com/1572_7599552b60454033a0d5c5e6d2e34ffb.html

best,

Mathieu

2016-02-22 9:30 GMT+01:00 Michael Sumner <mdsumner at gmail.com>: