[R] computing distance in miles or km between 2 street addre

Bert Gunter gunter.berton at gene.com
Fri Sep 7 01:33:34 CEST 2007


There is a well-known (greeedy) algorithm due to Dijkstra for choosing the
shortest path = minimum weight path on a weighted digraph between two
vertices. I'm sure numerous open source versions of this are available.
optim() is not relevant.


Bert Gunter
Genentech Nonclinical Statistics


-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Ted Harding
Sent: Thursday, September 06, 2007 3:18 PM
To: Philip James Smith; r-help at stat.math.ethz.ch
Subject: Re: [R] computing distance in miles or km between 2 street addre

On 06-Sep-07 18:42:32, Philip James Smith wrote:
> Hi R-ers:
> 
> I need to compute the distance between 2 street addresses in
> either km or miles. I do not care if the distance is a "shortest
> driving route" or if it is "as the crow flies."
> 
> Does anybody know how to do this? Can it be done in R? I have
> thousands of addresses, so I think that Mapquest is out of the
> question!
> 
> Please rely to: philipsmith at alumni.albany.edu
> 
> Thank you!
> Phil Smith

That's a somewhat ill-posed question! You will for a start
need a database of some kind, either of geographical locations
(coordinates) of street addresses, or of the metric of the
road network with capability to identify the street addresses
in the database.

If it's just "as the crow flies", then it can be straightforwardly
computed in R, either by Pythogoras (when they are not too far
apart) or using a function which takes account of the shape of
the Earth,

There are many R packages which have to do with mapping data.
Search for "map" through the list of R packages at

http://finzi.psych.upenn.edu/R/library/maptools/html/00Index.html

-- maptools in particular. Also look at (for instance) aspace.

For "shortest driving route" then you need to find the shortest
distance through a network. You may find some hints in the
package optim -- but there must be some R experts out there
on this sort of thing!

However, the primary need is for the database which gives
the distance information in one form or another. What were
you proposing to use for this? As far as I know, R has no
database relevant to street addresses!

Best wishes,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 06-Sep-07                                       Time: 23:17:57
------------------------------ XFMail ------------------------------

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list