Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R - How to convert latitude and longitude coordinates into an address/ human readable location?

Tags:

r

gps

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?

like image 426
Run Avatar asked Apr 28 '15 13:04

Run


People also ask

Can you get exact address with coordinates?

You can use a reverse geocoding tool or Google Maps to pull up the address listed at your given coordinates. Just be sure that you enter your coordinates accurately and include the minutes and seconds listed after each degree for precise results.


1 Answers

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)
like image 94
Sam Firke Avatar answered Oct 05 '22 06:10

Sam Firke