[R-sig-Geo] matrix distances

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Wed Aug 25 17:00:53 CEST 2010


On Wed, Aug 25, 2010 at 3:55 PM,  <jeremy.raw at dot.gov> wrote:
> There are a two ways that I am aware of to generate a matrix of point-to-point distances computed by traversing a network of roads:
>
> 1. One well-tested and reasonably fast solution is the igraph package on CRAN, using the shortest.paths function
>
> 2. There is a more specialized (and still experimental) package on R-Forge called travelr (of which I am the primary author) that is designed to support traffic assignment applications (http://r-forge.r-project.org/projects/travelr).  There is more setup involved than with igraph, but the tradeoff is that it is easier to get at the results that typically matter for travel demand models.
>
> Neither of these approaches works seamlessly with R spatial objects (it's on the agenda for travelr), but it's straightforward to make the conversion.  The gdistance package (also on R-forge) uses igraph to develop shortest paths across a grid, and illustrates the basic steps needed to make a structure of coordinates ready for analysis through igraph.

 Someone I know did write some python scripts that used http calls to
Google Maps to first lookup locations from UK postcodes and then use
google maps routing to compute both driving distance and crow-flies
distance. This involved lots of reverse engineering of google's http
interface for sending queries and then scraping the response. And was
probably against the google T+Cs, which might explain why every so
often the response was 'hey, are you a robot? fill in this captcha to
prove you arent'.

 No, wasn't me, honest guv.

Barry



More information about the R-sig-Geo mailing list