[GIS] Performing route analysis in R based on OSM transport network

osm2pgroutingpgroutingrrouting

I'm analysing the likely paths taken by commuters on their way to work, based on Census flow data, job density distributions and the transport network.

At the moment I'm using pgRouting and the pgRouting add-on for QGIS (described here) for my analysis:

routing in qgis

However, I'd like all the steps I take to be full replicable (see excellent article on this here), then I'd prefer to do my analysis from the command-line and save the script files for future reference.

R-geo packages fulfil this requirement well, as they are free, lightweight, and stable: download a tiny script file and you should be able to re-do all the things I have done (see here for an unrelated example of this on Rpubs).

The R packages I've identified for doing this are:

  • gdistance published December 2012, looks promising, but no sign of compatibility with osm transport networks
  • e1071 seems rather abstract and possibly overkill for what I want to do
  • pairdist.lpp function in spatstat package looks promising, but has little documentation

Before diving in to these, thought it worth asking people who may have faced similar dilemmas.

Is it possible to do my routing analysis in R, or would it be best to learn PostGIS properly and do it all in pgRouting?

Best Answer

Just to close this loose end, since I asked the question a new package was released called osmar which contains a vignette of how to implement shortest path algorithms in R using Open Street Map data: http://osmar.r-forge.r-project.org/ . It uses the function get.shortest.paths from the igraph package.

Excellent article on this can be found here: http://journal.r-project.org/archive/2013-1/eugster-schlesinger.pdf

And a tutorial by me can be found here: http://eprints.whiterose.ac.uk/77643/7/lovelace2.pdf

Related Question