【发布时间】:2019-07-04 13:50:26
【问题描述】:
我必须在 R 中对几个地址进行地理编码,但出现“已达到超时:10000 毫秒后连接超时”错误。我在办公室防火墙后面,所以也尝试使用代理,但仍然遇到同样的错误。
当我使用源作为“dsk”但它不会对大多数地址进行地理编码因此想使用“google”作为源时,这有效。
下面是我使用的一段代码。
library(ggmap)
library(curl)
register_google(key = "Have_Entered_My_API_Key_Here")
#Used below code to use proxy...(saw it as a solution in stackoverflow only for working behind firewall..maybe I'm not doing it the correct way?)
library(httr)
set_config(use_proxy(url="10.3.100.207",port=8080))
origAddress <- read.csv("Data_for_Geocoding.csv",header = TRUE,sep = ",",stringsAsFactors = FALSE)
for(i in 1:nrow(origAddress))
{
result <- geocode(origAddress$Add_to_GeoCode[i], output = "latlona", source = "google",sensor = TRUE)
origAddress$LONGITUDE[i] <- as.numeric(result[1])
origAddress$LATITUDE[i] <- as.numeric(result[2])
# origAddress$ <- as.character(result[3])
}
运行此代码时出现以下错误。
“curl::curl_fetch_memory(url, handle = handle) 中的错误:
已达到超时:连接在 10000 毫秒后超时”
我有数以千计的地址需要进行地理编码,如果有人能在这里提供帮助,我将不胜感激。
【问题讨论】:
标签: r geocoding google-geocoder reverse-geocoding google-geocoding-api