我在使用googleway包中的google_geocode功能批量地理編碼時遇到問題。我想輸入一個地址的數據框,併爲每個地址返回經度和緯度座標。地址數量遠遠超出Google的每日2500個查詢限制,因此解決方案需要使用API密鑰來允許購買更多的查詢。使用googleway批量地理編碼R
## Your Google API key
key<-"<insert key here>"
### Make Data Frame with two observations
Dt<-as.data.frame(matrix(c(" 4605 Langdon ST , Fernley , NV , 89408", -119.2026,
" 350 Quivera LN , Sparks , NV , 89441", NA), ncol=2))
###Change Column Names
colnames(Dt)<-c("address", "longitude")
### Make address column character
Dt$address<-as.character(Dt$address)
### Make data frame with one observation
dt<-Dt[1,]
### geocode one observation with googleway This Works!!
google_geocode(address = dt[,"address"],
key = key)
### batch geocode
res <- apply(Dt, 1, function(Dt){
google_geocode(address=list(Dt[,"address"]),
key = key)
})
## Error in Dt[, "address"] : incorrect number of dimensions
你的問題並不完全清楚。請更新您的問題,以反映發生了什麼。如果您想要設法規避Google的侷限性,那麼您很可能會面臨困難。 –
我不打算規避Google的侷限性,這就是爲什麼我需要一個使用我的API密鑰的解決方案,所以我將能夠每天接收並收到超過2500條結果。抱歉,我不清楚,我認爲批量地理編碼描述了我的需要;我將獲取存儲在數據框中的幾(千)個地址的緯度和經度座標。 – user3342735
@TFerrell - 這個問題是針對R包'googleway'的,因此如果您熟悉其中的一個/這兩個,則'清楚' – SymbolixAU