我正在尝试使用R库Ggmap对 vector 进行地理定位。
location_google_10000 <- geocode(first10000_string, output = "latlon",
source = "dsk", messaging = FALSE)
问题是我正在使用“dsk”(数据科学工具包API),因此它没有Google的速率限制(每天限制为2500个坐标)。但是,当我尝试使用包含2500以上的 vector 运行时,会弹出以下消息:
Error: google restricts requests to 2500 requests a day for non-business use.
我试图用具有1000个地址的dsk运行代码,然后检查是否实际使用了google或dsk api:
> geocodeQueryCheck()
2500 geocoding queries remaining.
因此,出于某种原因,它不允许我将超过2500个的“dsk”用于dsk,但我确信它不使用google。
最佳答案
我只是遇到了同样的问题并找到了您的帖子。我可以通过将client
和signature
值设置为虚拟值来解决此问题,例如
geocode(myLocations, client = "123", signature = "123", output = 'latlon', source = 'dsk')
问题似乎出在地理编码功能的这一部分...
if (length(location) > 1) {
if (userType == "free") {
limit <- "2500"
}
else if (userType == "business") {
limit <- "100000"
}
s <- paste("google restricts requests to", limit, "requests a day for non-business use.")
if (length(location) > as.numeric(limit))
stop(s, call. = F)
userType
在代码的这一部分上面设置了...if (client != "" && signature != "") {
if (substr(client, 1, 4) != "gme-")
client <- paste("gme-", client, sep = "")
userType <- "business"
}
else if (client == "" && signature != "") {
stop("if signature argument is specified, client must be as well.",
call. = FALSE)
}
else if (client != "" && signature == "") {
stop("if client argument is specified, signature must be as well.",
call. = FALSE)
}
else {
userType <- "free"
}
因此,如果
client
和signature
参数为空,则userType
设置为“免费”,然后将限制设置为2500。通过提供这些参数的值,您将被视为“业务”用户,限制为100,000。如果假定用户使用的是“dsk”而不是“dsk”,那么这是一个很好的检查,但是如果源是“dsk”,则过于热情,应该将其覆盖。简单起见,也许像... if (source == "google") {
if (client != "" && signature != "") {
if (substr(client, 1, 4) != "gme-")
client <- paste("gme-", client, sep = "")
userType <- "business"
}
else if (client == "" && signature != "") {
stop("if signature argument is specified, client must be as well.",
call. = FALSE)
}
else if (client != "" && signature == "") {
stop("if client argument is specified, signature must be as well.",
call. = FALSE)
}
else {
userType <- "free"
}
} else {
userType <- "business"
}
但是,如果为其他来源计划了
client
或signature
参数,则将导致问题。我将对软件包作者进行ping操作。关于r - ggmap “dsk”速率限制,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42282492/