14

How can I convert latitude and longitude coordinates into an address/ human readable location in R?

For instance I have these data below:

humandate           lat         lon     
09/10/2014 13:41    41.83174254 -75.87998774    
09/10/2014 13:53    41.83189873 -75.87994957

I want find out what the address/ location is for latitude 41.83174254, longitude -75.87998774. Is it possible with R? or with something else?

Sam Firke
  • 21,571
  • 9
  • 87
  • 105
Run
  • 54,938
  • 169
  • 450
  • 748
  • 2
    I think this is probably best asked on GIS SE. I don't know of a package in R that obtains addresses from coordinates, but there might be a way to use R to interface to a database that does have this information. – Phil Apr 28 '15 at 14:04
  • 2
    This may help you, but not R http://stackoverflow.com/questions/10008949/is-it-possible-to-get-an-address-from-coordinates-using-google-maps – Math Apr 28 '15 at 14:15

1 Answers1

30

Use the revgeocode function from the ggmap package. Using your data.frame df:

revgeocode(c(df$lon[1], df$lat[1]))

"27-37 Beech Street, Montrose, PA 18801, USA"

You could create a new variable in your data.frame with these values:

df$textAddress <- mapply(FUN = function(lon, lat) revgeocode(c(lon, lat)), df$lon, df$lat)
Sam Firke
  • 21,571
  • 9
  • 87
  • 105