I was using google map API to get the coordinates for Fortune500 companies with geoocode
However, when I ran it, it still showed OVER_QUERY_LIMIT
periodically and thus my geocode list is not complete. So I have 2 questions:
- how to get all the geocodes(was my code wrong)?
- how to edit my API key in R environment & source it in my code?
To get Fortune500 list:
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")
Trouble getting coordinates for all Fortune500 companies in the following:
# 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
Thank you for your help.