2017-02-16 115 views
1

我尝试使用R库Ggmap进行地理定位。Ggmap“dsk”速率限制

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

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

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

我曾试图用1000个地址上运行与DSK的代码,后来检查,如果确实谷歌或DSK API已经被使用:

> geocodeQueryCheck() 
2500 geocoding queries remaining. 

所以,由于某种原因,它不会允许我使用超过2500个的“DSK”,但我相信它不是使用谷歌。

回答

3

我刚刚遇到同样的问题,并找到您的帖子。我能够通过将clientsignature值设置为虚拟值来解决此问题,例如,

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

所以,如果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" 
} 

这会造成问题,如果clientsignature参数计划在其它来源虽然。我会ping包装作者。

+0

谢谢!它有些作品,但仍然有限。原因是尽管使用虚拟值跳过了2500的限制,但现在它停止在商业Google的限制,即10,000:错误:谷歌将请求限制为每天100000个请求,以供非业务使用。 –