In January 2019, Google updated their terms of service and has essentially removed the free access to Google Maps in R. This means that you’ll need to purchase the relevant APIs (compu-speak for Application Programming Interface) from Google in your google account to access these features in R.
So do you need it?
If you’re interested in mapping in R, you basically need it. There are some mapping packages that you can use to get around using any Google products (Leaflet is a great example). But for all the glorious customization and overwhelming ubiquity of the ggmap, this API key is essential for reproducible science in ecology related fields. When I first encountered the problem, troubleshooting was a nightmare–everyone used ggmap, and even those who didn’t still used Google Maps as a source for their base maps. Not. Fun.
Luckily, it’s relatively cheap at $2/month for the first 100,000 static maps in each month (dynamic maps, street maps, embed advance, and dynamic street maps cost more, but we aren’t likely using these tools in our work). Even luckier, there’s a $200 credit/month for the first year of use!
It’s a bit confusing to navigate the Google Cloud Console if you’re trying to figure it out solo (and scary considering you’re paying for something), but the actual steps are easy and quick. There are two main steps to the process: 1)Get an API key and 2) Show R your API key. There’s just a few ministeps in between.
Get an API key:
- Go to this website.
- Pick your product (Maps).
- Select a Project. If you don’t have one, create one. It won’t matter later.
- Enter your billing information.
- Copy your API key. Consider pasting it into a .txt file on your machine for safe keeping.
Show R your API key:
- In your R console, enter this code:
- register_google(key = “YOUR_API_KEY”)
- Run this code for every new session you need to map in, and you’re ready to go!
a daRk tuRn
R is popular among scientists (especially ecology/conservation scientists) because of its power. But it’s basically essential for scientists because it’s free. In a field where funding is scarce and costs are high, R has been a blessing for open science and has seriously moved the discipline forward. But the same reason R is powerful is because it’s not entirely autonomous; it (in large part) relies on monolithic companies like Google to up the ante. It may not be a very expensive fee, but it is yet another barrier for researchers and open science. Hopefully someday we can return to a free, open access Google Maps. After all, open science benefits scientists, the general public, and corporations–even Google.