Philip James Smith
2007-Sep-06 18:42 UTC
[R] computing distance in miles or km between 2 street addresses
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
(Ted Harding)
2007-Sep-06 22:17 UTC
[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 SmithThat'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 ------------------------------