首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ggmap "dsk“速率限制

Ggmap "dsk“速率限制
EN

Stack Overflow用户
提问于 2017-02-17 03:01:42
回答 1查看 1.1K关注 0票数 2

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

代码语言:javascript
复制
location_google_10000 <- geocode(first10000_string, output = "latlon",
    source = "dsk", messaging = FALSE)

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

代码语言:javascript
复制
Error: google restricts requests to 2500 requests a day for non-business use.

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

代码语言:javascript
复制
> geocodeQueryCheck()
2500 geocoding queries remaining.

因此,出于某种原因,它不允许我使用超过2500的"dsk",但我确定它不使用谷歌。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-03-05 11:29:36

我刚刚遇到了同样的问题,找到了你的帖子。我可以通过将clientsignature值设置为虚拟值来解决这个问题。

代码语言:javascript
复制
geocode(myLocations, client = "123", signature = "123", output = 'latlon', source = 'dsk')

问题似乎出在地理编码函数的这一部分...

代码语言:javascript
复制
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 ...

代码语言:javascript
复制
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"
    }

因此,如果clientsignature参数为空,则将userType设置为“空闲”,进而将限制设置为2,500。通过提供这些参数的值,您将被视为限制为100,000的“业务”用户。如果假设用户使用'Google‘而不是'dsk’作为源,这是一个很好的检查,但如果源是'dsk‘,则检查过度,可能应该被覆盖。简单的说也许是这样的.

代码语言:javascript
复制
    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"
 }

但是,如果clientsignature参数是为其他来源计划的,这将会带来问题。我将ping包的作者。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42282492

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档