简体   繁体   中英

registration for using maps in R plots with ggmap and googleAuthR

easy way to register for googleAuthR such that I could make bubble plots on maps in R? Here is what I have been trying:

library(ggmap)
library(googleAuthR)
install.packages("googleAuthR")
# get the map info
remotes::install_github("abc@gmail.com/googleAuthR")
gar_auth(email = "abc@gmail.com")
map <- get_googlemap("Montpellier, France", zoom = 8, maptype = "terrain")

It looks as if the method for registering the Google API key has changed a time or two from the time when the API was completely free.

I registered with Google for the Google mapping API key a couple of months ago. Then I only needed to set the API Key on the PC once. After registering the API key on the PC, all the Google Map API requests happen without any issues.

While registering at Google for the API Key, Google recommends several options to safeguard your API key. I choose to limit the daily activity for each of the various Google Map API Apps. Sometimes while coding I reach those daily limits. The daily limits can be changed, but Google doesn't update those changes until mid-night.

I inserted the following line of registration code into some random Jupyter Notebook project I was working on a few months ago. I don't remember what the project was or what it is named. I set the API Key once on the PC and then all was good. I was coding in R and I set the API key using R. There will likely be different code when registering using python. And to permanently set the API Key in R, use the, write - TRUE, option.

Here's that code. The quotes are required around the API Key.

register_google(key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", write = TRUE)

Here is the update after managing to plot this: ggmap with geompoint on map

What I have learned: You need to update quite some google APIs to get to different areas of the world else it locked me out of certain countries. "OSM" now shows as defunct in R and I could not play with the color of the sea in the toner map; Further I did try and install Java etc in R to get it running for different types; Later realized that it was now defunct after inquiry in R; What I have used here is free using get_stamenmap, bbox, geompoint and geomlabel as a simple 4 line code. cheers and hope this info helps someone in the future.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM