Ggmap“dsk”费率限制 [英] Ggmap "dsk" rate limit

查看:224
本文介绍了Ggmap“dsk”费率限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

 错误:google限制每天请求2500次请求以供非商业用途使用。 

我试着用1000个地址的dsk运行代码,然后检查实际上是google还是dsk api已被使用:

 > geocodeQueryCheck()
2500个地理编码查询剩余。

所以出于某种原因,它不允许我在dsk中使用超过2500,但我确信它没有使用google。

解决方案

我刚刚遇到同样的问题并找到您的帖子。我可以通过将客户端签名值设置为虚拟值来解决此问题,例如

  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限制请求)
if(长度(位置)> as.numeric(限制))
stop(s,call。= F)

userType 在此部分中设置代码...

  if(client!=&&&signature; =){
if(substr(client ,1,4)!=gme-)
客户端< - paste(gme-,client,sep =)
userType< - business
}
else if(client ==&&签名!=){
stop(如果指定了签名参数,客户端必须也是。,
call。= FALSE)
}
else if ($$)= $&&&& signature ==){
stop(如果指定了客户端参数,则签名必须是。,
call。= FALSE)
}
else {
userType< - free
}

因此,如果客户端签名参数为空 userType 设置为空闲,然后将限制设置为2,500。通过提供这些参数的值,您被视为具有100,000个限制的商业用户。如果用户被假定为使用'Google'而不是'dsk'作为源,但是如果源是'dsk'并且应该可能被覆盖,这是一个很好的检查。如果(源==谷歌){
如果($ {


 if(substr(client,1,4)!=gme-)
client< - paste(gme- ,client,sep =)
userType< - business
}
else if(client ==&&& signature!=){
stop(如果指定了签名参数,客户端必须也是。,
call。= FALSE)
}
else if(client!=&&&&&&&&&&& ==){
stop(如果指定了客户端参数,签名必须也是。,
call。= FALSE)
}
else {
userType< - free
}
} else {
userType< - business
}

这会导致问题但如果客户端签名参数是为其他来源计划的。我会ping包作者。


I am tryng to geolocate a vector making use of the R library Ggmap.

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

The problem is that I am using "dsk" -The data science toolkit API- and therefore it has not rate limits as Google (limites to 2500 coordinates per day). However, when I try to run with a vector that contains more than 2500, it pops the following message:

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

I have tried to run the code with dsk with 1000 addresses, and later checking if actually google or dsk api has been used:

> geocodeQueryCheck()
2500 geocoding queries remaining.

So for some reason it does not allow me to use more than 2500 with the "dsk", but I am sure that its not using google.

解决方案

I just ran into the same issue and found your post. I was able to work around this by setting the client and signature values to dummy values, e.g.

geocode(myLocations, client = "123", signature = "123", output = 'latlon', source = 'dsk')

The issue appears to be with this part of the geocode function...

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 is set above in this part of the code...

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"
    }

So, if client and signature parameters are empty userType is set to "free" and in turn the limit is set to 2,500. By providing values for these parameters you are seen as a 'business' user with a limit of 100,000. This is a good check if the user is assumed to be using 'Google' as opposed to 'dsk' as the source, but is overzealous if the source is 'dsk' and should probably be overridden. To be simple minded maybe something like...

    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"
 }

That would cause problems if client or signature parameters were planned for other sources though. I'll ping the package author.

这篇关于Ggmap“dsk”费率限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆