【发布时间】:2019-08-31 09:26:09
【问题描述】:
我正在尝试使用ggmap 包中的geocode() 函数对R 中的地址进行地理编码。我在我的个人计算机上相对容易地完成了这个,并想在我的工作计算机上尝试这个。一般来说,我应该在谷歌注册,库ggmap包,读入我的安全密钥,然后我可以使用geocode()函数。但我得到错误。见下文:
# Library package
library(ggmap)
# Set key file
gmAPI <- "key_file.txt"
# Read-in Google API key
gmAPIKey <- readLines(gmAPI)[1]
# Register key
register_google(key = gmAPIKey)
# Geocode Waco, TX
geocode("waco, texas", output = "latlona")
我收到的不是生成地理编码输出,而是:
Source : https://maps.googleapis.com/maps/api/geocode/json?address=waco,+texas&key=xxx.txt
Error in curl::curl_fetch_memory(url, handle = handle) :
Failed to connect to maps.googleapis.com port 443: Timed out
或者有时:
Source : https://maps.googleapis.com/maps/api/geocode/json?address=waco,+texas&key=xxx.txt
Error in curl::curl_fetch_memory(url, handle = handle) :
Failed to connect to url port ###: Connection refused
注意:我用 url port ### 替换了错误消息中发布的实际 url/端口,因为我想这是特定于我的计算机的。
我感觉这与我的工作网络有关。 Similar questions 使用 httr 包设置了一些配置,但这些解决方案对我不起作用。有可能我输入了错误的信息。有什么帮助吗?
【问题讨论】:
标签: r geocoding google-geocoder ggmap google-geocoding-api