I have a list of street addresses I would like to geocode to county. I am working in R. Simplified example follows. Unfortunately, due to the new Google API terms of service, you will need to have your own API key to run my code--it should not be shared, so please do not include it in your solution code.
I suspect this is a formatting issue but I am too new to R to know the solution.
library(tidyverse)
library(ggmap)
register_google(key = <YOUR GOOGLE KEY>)
ltr <- letters %>% head(5)
adr <- c('110 State St, Albany, NY' ,
'100 State Cir, Annapolis, MD' ,
'206 Washington St SW, Atlanta, GA' ,
'210 State St, Augusta, ME' ,
'1100 Congress Ave, Austin, TX')
rawAdr <- data.frame(ltr , adr)
# the following only retrieves latitude and longitude
latlonAdr <- geocode(location = rawAdr$adr) %>%
bind_cols(rawAdr , .)
# the following retrieves county (among much other information),
# but it is formatted in a way that is
# impossible to use. For instance, county a is in variable long_name...17,
# but the same name is repeated for all addresses. The county for address b is given in
# long_name...64, again the same name for all addresses.
geoAdr <- geocode(location = rawAdr$adr , output = 'all') %>%
bind_cols(rawAdr , . )
I would like to have a file that lists ltr, adr and (correct) county. Thanks for your any help! (Apologies, I will not be able to look at answers for a couple of hours.)