This notebook demonstrates how to geocode a set of addresses in a data frame. In this case, the ‘addresses’ consist of city, state, and country (only).
1) Import the Addresses
library(googlesheets4)library(dplyr)## Note: this Google Sheet is private, so this will only work if you've already ## authenticated.reg_city_state_tbl<-read_sheet(ss ="1vWhj9AcYin2nCnAzG5JpQ7179BQvhZeJpK5b6yz7IrE", sheet ="Locations")|>rename(city =City, state =`State/Province`, country =Country)
ℹ The googlesheets4 package is using a cached token for 'andlyons@ucdavis.edu'.
Auto-refreshing stale OAuth token.
✔ Reading from "2025-11-07 Spatial Data Fundamentals in R (Responses)".
tidygeocoder supports over ten geocoding services. We’ll use the ArcGIS geocoding service. Even though we aren’t passing an API key, ArcGIS will let us geocode the addresses one at a time.
## Use the ArcGIS Single Address Geocoderreg_gc_arcgis_tbl<-reg_city_state_tbl|>geocode(city =city, state =state, country =country, method ="arcgis", full_results =TRUE)
Passing 25 addresses to the ArcGIS single address geocoder