Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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. So: 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?

share|improve this question

1 Answer 1

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

share|improve this answer
Thanks for looking into this. You are the MVP. Any pointers you have leared in the year or so since your answer? –  Fabián Heredia Montiel Feb 21 at 3:50
I would say calling online route service apis from within R is the main innovation I've learned this year - one way described here: journal.r-project.org/archive/2013-1/kahle-wickham.pdf routino is also good, not used it though –  RobinLovelace Feb 21 at 12:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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