【问题标题】:Ggmap "dsk" rate limitggmap“dsk”速率限制
【发布时间】:2017-02-16 19:01:41
【问题描述】:

我正在尝试使用 R 库 Ggmap 对矢量进行地理定位。

location_google_10000 <- geocode(first10000_string, output = "latlon",
    source = "dsk", messaging = FALSE)

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

Error: google restricts requests to 2500 requests a day for non-business use.

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

> geocodeQueryCheck()
2500 geocoding queries remaining.

所以由于某种原因,它不允许我使用超过 2500 的“dsk”,但我确信它没有使用 google。

【问题讨论】:

    标签: r geolocation geocoding ggmap google-geocoding-api


    【解决方案1】:

    我刚刚遇到了同样的问题并找到了您的帖子。我可以通过将 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 设置为“免费”,然后限制设置为 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"
     }
    

    如果 client 或 signature 参数被计划用于其他来源,这将导致问题。我会 ping 包作者。

    【讨论】:

    • 谢谢!它有点工作,但仍然有限。原因是,虽然使用 dummy 值跳过了 2500 的限制,但现在它停止了业务 Google 的限制,即 10,000:错误:google 将请求限制为每天 100000 个请求以供非业务使用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-13
    • 2020-11-04
    • 2021-01-22
    • 1970-01-01
    相关资源
    最近更新 更多