无法使用Google API

时间:2018-03-05 12:46:01

标签: r api google-maps ggmap geocode

我使用谷歌地图API来获取geoocode财富500强企业的坐标但是,当我运行它时,它仍然会定期显示OVER_QUERY_LIMIT因此我的地理编码列表不完整。所以我有两个问题:

  1. 如何获取所有地理编码(我的代码错了)?
  2. 如何在R环境中编辑我的API密钥&在我的代码中找到它?
  3. 获得Fortune500名单:

        library(XML)
        library(RCurl)
        fortune500_url <- getURL("https://www.geolounge.com/fortune-500-list-by-
        state-for-2015/",.opts = list(ssl.verifypeer = FALSE) ) 
        fortune500 = readHTMLTable(fortune500_url, header = TRUE, which = 1)
        colnames(fortune500) <- tolower(colnames(fortune500))
        fortune500 <- 
        subset(fortune500,select=c("company","streetadd","place","state","zip"))
        write.csv(fortune500, "fortune500.csv")
    

    无法获得以下所有Fortune500公司的坐标:

        # Add API key to renviron file
        usethis::edit_r_environ() # how do we assign API key to a variable?
    
        # Install Developer version of ggmap to use maps API Key
    
        devtools::install_github("dkahle/ggmap")
        library(ggmap)
    
        register_google(key = Sys.getenv("MY_API_KEY")) # how to source my key from R environment ?
    
        fortune500$address <- paste(fortune500$streetadd, fortune500$place, 
        fortune500$state, fortune500$zip)
    
        geocodes <- geocode(fortune500$address, output = "latlon" , source = 
        "google")    # can't get all coordinates
    

    感谢您的帮助。

0 个答案:

没有答案