Skip to contents

qualocep_download() retrieves a validated dataset from Qual o CEP hosted on the package's OSF repository.

Qual o CEP is a database of Brazilian addresses and postal codes, geocoded using the Google Geocoding API. Users should verify the year of the data, as some values may be outdated.

When possible, consider using the geocodebr package, which provides more up-to-date geocoded information.

Note: This function requires an internet connection to work and the osfr package to be installed.

Usage

qualocep_download(file = NULL, pattern = "2024-11-12.rds", force = FALSE)

Arguments

file

(optional) A character string with the path to a Qual o CEP dataset file. If NULL, the dataset will be downloaded from the package's OSF repository. (default: NULL).

pattern

(optional) A character string with the pattern of the Qual o CEP dataset file to download. Click here to see the available patterns (default: "2024-11-12.rds").

force

(optional) A logical flag to force the download of the Qual o CEP dataset file. If TRUE, the dataset will be downloaded even if it already exists in the temporary directory (default: FALSE).

Value

A tibble containing the Qual o CEP with the following columns:

  • postal_code: A character vector with the postal codes.

  • street_type: A character vector with the type of streets.

  • street_name: A character vector with the name of the streets.

  • street: A character vector with the full name of the streets.

  • complement: A character vector with the complement of the addresses.

  • place: A character vector with the place of the addresses.

  • neighborhood: A character vector with the neighborhoods

  • municipality_code: An integer vector with the codes of the Brazilian Institute of Geography and Statistics (IBGE) for Brazilian municipalities.

  • municipality: A character vector with the name of the municipalities.

  • state_code: An integer vector with the codes of the Brazilian Institute of Geography and Statistics (IBGE) for the Brazilian state.

  • state: A character vector with the name of the states.

  • federal_unit: A character vector with the abbreviations of the Brazilian federal unit.

  • latitude: A numeric vector with the latitude values of the postal codes (retrieved using Google Geocoding API).

  • longitude: A numeric vector with the longitude values of the postal codes (retrieved using Google Geocoding API).

Examples

library(curl)
library(dplyr)

# \dontrun{
  if (has_internet()) {
    qualocep_download() |> glimpse()
  }
#>  Downloading Qual o CEP data from OSF
#>  Downloading Qual o CEP data from OSF [11.2s]
#> 
#> Rows: 1,396,087
#> Columns: 14
#> $ postal_code       <chr> "69945000", "69945959", "69945970", "69935000", "…
#> $ street_type       <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N
#> $ street_name       <chr> NA, "Avenida Paraná, 296 Clique e Retire Correios…
#> $ street            <chr> "NA NA", "NA Avenida Paraná, 296 Clique e Retire …
#> $ complement        <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N
#> $ place             <chr> NA, "AC A C Retire", "AC Acrelândia", NA, "AC A B…
#> $ neighborhood      <chr> NA, "Centro", "Centro", NA, "Centro", "Centro", N
#> $ municipality_code <int> 1200013, 1200013, 1200013, 1200054, 1200054, 1200…
#> $ municipality      <chr> "Acrelândia", "Acrelândia", "Acrelândia", "Assis …
#> $ state_code        <int> 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 1…
#> $ state             <chr> "Acre", "Acre", "Acre", "Acre", "Acre", "Acre", "…
#> $ federal_unit      <chr> "AC", "AC", "AC", "AC", "AC", "AC", "AC", "AC", "…
#> $ latitude          <dbl> -10.0764608, -10.0766582, -10.0764270, -10.931854…
#> $ longitude         <dbl> -67.0586512, -67.0557312, -67.0555998, -69.563862…
# }