1

I'm trying find libraries for R that would find the shortest route between two locations, given a SpatialLinesDataFrame representing the road network. All I could find was stplanr, which delegates the routing to external services such as CycleStreets.net (which does not cover the area I'm interested in) or GraphHopper (which is expensive).

What am I missing? Are there open routing packages for R available on GitHub or CRAN?

(My preference on an R package is due to the routing solution being a part of a larger application, and a native lib would be easier to integrate.)

  • 1
    Hmm, may be that I've been looking in the wrong direction. It appears you can convert SpatialLinesDataFrames to igraph objects using, for example, the shp2graph library. igraph objects, in turn, can easily be queried for shortest paths between edges (see igraph::get.shortest.paths()). See example (without shp2graph) here: rstudio-pubs-static.s3.amazonaws.com/…. – Lauri Lovén Sep 26 '16 at 9:15
  • The SpatialLinesDataFrame -> igraph -> Dijkstra method is very slow with the road network of one medium-sized city, though, and even seems to occasionally crash R. Another package, gdistance seems to be doing the right thing, but with rasters rather than road networks. It could perhaps be used, writing a Transition wrapper for the SpatialLinesDataFrame road network. – Lauri Lovén Sep 26 '16 at 11:35
  • Did you try the TSP ( Traveling Salesperson Problem)? – Guzmán Sep 26 '16 at 15:12
1

Together with the stplanr authors I started some work on this in https://github.com/edzer/spnetwork , but I'm not so sure this is helpful - we stopped developing it at some stage, mostly because stplanr went for routing services. You may also want to look at CRAN package osmar, but I doubt that sees active development.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.