2017-02-16 61 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個請求,以供非業務使用。 –