Skip to content

Instantly share code, notes, and snippets.

@rafapereirabr
Created September 18, 2020 18:51
Show Gist options
  • Save rafapereirabr/9821867367e393889e38a859da7bcb6c to your computer and use it in GitHub Desktop.
Save rafapereirabr/9821867367e393889e38a859da7bcb6c to your computer and use it in GitHub Desktop.
geocode_google_api

library(ggmap)
library(data.table)

# registrar Google API Key
register_google(key = 'xxxxx-xxxxxx-xxxxx-xxxxx')


# lista com enderecos
addresses <- c('Rua Um N. 50, Goiânia, Goiás, CEP 71665-020',
               'Avenia Dois N. 72, São Luiz, Maranhão, CEP 70233-410')

# geocode (retorna uma lista)
coordenadas_google <- lapply(X=addresses, ggmap::geocode, output="all")

# empilha como data.frame
coordenadas_google_df <- data.table::rbindlist(coordenadas_google)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment