本文介绍了使用地理编码发出一个请求后超过查询限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 ggmap 的地理编码来查找不同城市的纬度和经度.昨天它运行得很好,但我今天只收到了​​一个请求就收到了 OVER QUERY LIMIT.

I'm using the ggmap's geocode to find the latitude and longitude of different cities. It worked completely fine yesterday but I get an OVER QUERY LIMIT after only one request today.

事实上,如果我只是加载库并运行地理编码,它会抛出 OVER QUERY LIMIT 错误:

In fact if I just load the library and run geocode it throws the OVER QUERY LIMIT error:

> library(ggmap)
> geocode("Paris")
Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=Paris&sensor=false
  lon lat
1  NA  NA
Warning message:
geocode failed with status OVER_QUERY_LIMIT, location = "Paris"

我在 stackoverflow 上查看了不同的主题,但似乎没有人遇到同样的问题.我试图看看我是否超过了 2500 限制(不太可能,但我是编码新手,所以也许我做错了什么......)并且 geocodeQueryCheck() 读取 2498 但是每次我运行 library(ggmap) 时它再次重置.

I checked different topics on stackoverflow but nobody seems to have the same problem.I tried to see if I was over the 2500 limit (very unlikely but I'm new to coding so maybe I did something wrong...) and geocodeQueryCheck() reads 2498 but then again it resets every time I run library(ggmap).

十五分钟前当我重新启动 Rstudio 时它工作过一次,但现在它不再工作了,我完全迷失了!

It worked once fifteen minutes ago when I rebooted Rstudio but now it doesn't work anymore, I'm completely lost!

有人知道可能是什么问题吗?

Does anyone have any idea what might be the problem?

PS:我是 stackoverflow 的新手,所以如果您对任何事情有任何意见,请告诉我!

PS: I'm new to stackoverflow so if you have any remark on anything please tell me!

推荐答案

我在使用 ggmap::geocode() 时遇到了类似的问题,其中大约 20% 的位置给了 OVERQUERY LIMIT 错误,即使 geocodeQueryCheck() 会显示剩余的地理编码查询绰绰有余,并且错误零星分布在各个位置,而不仅仅是最后 20%.如果我重新运行第一次失败的位置子集,那么大多数都可以工作,所以我必须遍历较小的子集,直到它们都具有地理编码.

I had a similar problem using ggmap::geocode() for a batch of locations where roughly 20% of locations gave the OVER QUERY LIMIT error even though geocodeQueryCheck() would show more than enough geocoding queries remaining, and the errors were sporadically spread throughout the locations, not just the last 20%. If I reran the subset of locations that failed the first time, again most would work, so I had to iterate through smaller subsets until they all had geocodes.

ggmap v2.7 允许用户通过 register_google() 函数指定 Google Maps API 密钥.v2.7 还没有在 CRAN 上,所以你必须使用 devtools::install_github("dkahle/ggmap") 来安装它.更新到该版本并设置我的 API 密钥 register_google(key = "my_api_key") 后,同一批次按预期运行一次.

ggmap v2.7 allows the user to specify a Google Maps API key through the register_google() function. v2.7 is not on CRAN yet, so you have to use devtools::install_github("dkahle/ggmap") to install it. After updating to that version and setting my API Key register_google(key = "my_api_key"), the same batch worked in one run as expected.

Google Maps API Key 很容易获得:https://developers.google.com/maps/documentation/geocoding/get-api-key

The Google Maps API Key is easy to get:https://developers.google.com/maps/documentation/geocoding/get-api-key

这篇关于使用地理编码发出一个请求后超过查询限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 16:08
查看更多