Ggmap"dsk"速率限制

Jav*_*ler 2 geocoding r geolocation google-geocoding-api ggmap

我正在尝试使用R库Ggmap对地图进行地理定位.

location_google_10000 <- geocode(first10000_string, output = "latlon",
    source = "dsk", messaging = FALSE)
Run Code Online (Sandbox Code Playgroud)

问题是我正在使用"dsk" - 数据科学工具包API-因此它没有速率限制为谷歌(限制为每天2500坐标).但是,当我尝试使用包含超过2500的向量运行时,它会弹出以下消息:

Error: google restricts requests to 2500 requests a day for non-business use.
Run Code Online (Sandbox Code Playgroud)

我尝试使用带有1000个地址的dsk运行代码,然后检查是否实际使用了google或dsk api:

> geocodeQueryCheck()
2500 geocoding queries remaining.
Run Code Online (Sandbox Code Playgroud)

所以出于某种原因,它不允许我使用超过2500与"dsk",但我相信它不使用谷歌.

use*_*498 5

我刚遇到同样的问题,发现了你的帖子.我能够通过将clientsignature值设置为虚拟值来解决这个问题,例如

geocode(myLocations, client = "123", signature = "123", output = 'latlon', source = 'dsk')
Run Code Online (Sandbox Code Playgroud)

这个问题似乎与地理编码功能的这一部分有关......

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)
Run Code Online (Sandbox Code Playgroud)

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"
    }
Run Code Online (Sandbox Code Playgroud)

因此,如果clientsignature参数为空,userType则设置为"空闲",然后将限制设置为2,500.通过为这些参数提供值,您将被视为"业务"用户,其限制为100,000.如果假设用户使用'Google'而不是'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"
 }
Run Code Online (Sandbox Code Playgroud)

如果client或者signature为其他来源计划参数,那将导致问题.我会ping包的作者.