> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Duncan Murdoch > Sent: Thursday, September 06, 2007 4:54 PM > To: [EMAIL PROTECTED] > Cc: r-help@stat.math.ethz.ch; Philip James Smith > Subject: Re: [R] computing distance in miles or km between 2 > street addre > > On 06/09/2007 6:17 PM, (Ted Harding) wrote: > > 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: [EMAIL PROTECTED] > >> > >> 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! > > But if the addresses are in the US and include zip codes, a > database is > available online for free, here: > > http://www.aggdata.com/files/zip_codes.zip > > This includes latitude and longitude. Zip codes cover a fairly large > area so this won't give very accurate information, but it's > easy to get. > > Duncan Murdoch >
There are a number of free address geocoding sites on the web, some of which even support moderate amounts of batch geocoding for non-commercial purposes. The following URL is just one of the available sites turned up by Googling "address geocoding free". Of course, there are also a number of commercial sites. http://www.batchgeocode.com/ Hope this is helpful, Dan Daniel J. Nordlund Research and Data Analysis Washington State Department of Social and Health Services Olympia, WA 98504-5204 ______________________________________________ R-help@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.