这是我的示例数据集(称为 origAddress):
lat lng
1.436316 103.8299
1.375093 103.8516
1.369347 103.8398
1.367353 103.8426
我有更多的纬度和经度数字(330),我想找到地址。我用这个 for 循环来做到这一点:
for(i in 1:nrow(origAddress))
{
# Print("Working...")
result <- google_reverse_geocode(location = c(origAddress$lat[i],origAddress$lng[i]),
key = key,
location_type = "rooftop")
if(is.null(result) || length(dim(result)) < 2 || !nrow(result)) next
origAddress$venadd <- geocode_address(result)
}
它适用于前三或四行,但随后返回与第一行相同的地址,尽管纬度和经度数字肯定不同。我查看了其他 stackoverflow 问题(此处)并尝试复制他们的方法,但结果相似。
请帮忙!