Skip to contents

Takes a data frame containing addresses as an input and returns the spatial coordinates found based on CNEFE data.

Usage

geocode_rafa(
  addresses_table,
  address_fields = setup_address_fields(),
  n_cores = 1,
  progress = TRUE,
  cache = TRUE
)

Arguments

addresses_table

A data frame. The addresses to be geocoded. Each column must represent an address field.

address_fields

A character vector. The correspondence between each address field and the name of the column that describes it in addresses_table. The setup_address_fields() function helps creating this vector and performs some checks on the input. Address fields passed as NULL are ignored and the function must receive at least one non-null field. If manually creating the vector, please note that the vector names should be the same names used in the setup_address_fields() parameters.

n_cores

A number. The number of cores to be used in parallel execution. Defaults to 1.

progress

A logical. Whether to display progress bars when downloading CNEFE data and when geocoding the addresses. Defaults to TRUE.

cache

A logical. Whether CNEFE data should be saved to/read from cache, reducing processing time in future calls. Defaults to TRUE. When FALSE, CNEFE data is downloaded to a temporary directory.

Value

An arrow Dataset or a "data.frame" object.

Examples


data_path <- system.file("extdata/small_sample.csv", package = "geocodebr")
input_df <- read.csv(data_path)

fields <- setup_address_fields(
  logradouro = "nm_logradouro",
  numero = "Numero",
  cep = "Cep",
  bairro = "Bairro",
  municipio = "nm_municipio",
  estado = "nm_uf"
)

#df <- geocodebr:::geocode_rafa(
#  addresses_table = input_df,
#  address_fields = fields,
#  progress = FALSE
#  )
#
#head(df)