How can I convert latitude and longitude coordinates into an address/ human readable location in R?
如何将纬度和经度坐标转换为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?
我想查一下纬度41.83174254,经度-75.87998774的地址/位置。用R可以吗?或者其他什么?
1 个解决方案
#1
24
Use the revgeocode
function from the ggmap
package. Using your data.frame df
:
使用ggmap包中的revgeocode函数。用你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)
#1
24
Use the revgeocode
function from the ggmap
package. Using your data.frame df
:
使用ggmap包中的revgeocode函数。用你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)