
Get a Brazilian address by its postal code via reverse geocoding
Source:R/get_brazil_address_by_postal_code.R
get_brazil_address_by_postal_code.Rd
get_brazil_address_by_postal_code()
retrieves a Brazilian address based
on a postal code using
reverse geocoding.
Please note that the accuracy of the results may vary depending on the method used.
Usage
get_brazil_address_by_postal_code(
postal_code,
method = "qualocep",
fix_code = TRUE,
limit = 10
)
Arguments
- postal_code
A
character
vector with the postal code(s) to be used to. The postal code must be in the formatXXXXXXXX
, whereX
is a digit.- method
(Optional) A
character
value indicating the method to be used to retrieve the address data. The available options are"osm"
,"google"
,"qualocep"
, and"viacep"
(Default:qualocep
).- fix_code
(Optional) A
logical
flag indicating if the postal code must be fixed before being used (Default:TRUE
).- limit
(Optional) A
numeric
value indicating the maximum number of results to return. If the value isInf
, all postal codes will be used (Default:10
).
Value
A tibble
with the following columns:
postal_code
: Acharacter
vector with the postal codes.street
: Acharacter
vector with the full names of the streets.complement
: Acharacter
vector with the complements of the addresses.neighborhood
: Acharacter
vector with the neighborhoods.municipality_code
: Aninteger
vector with the codes of the Brazilian Institute of Geography and Statistics (IBGE) for Brazilian municipalities.municipality
: Acharacter
vector with the names of the municipalities.state_code
: Aninteger
vector with the codes of the Brazilian Institute of Geography and Statistics (IBGE) for the Brazilian states.state
: Acharacter
vector with the names of the states.region
: Acharacter
vector with the Brazilian regions.address
: Acharacter
vector with the full addresses.latitude
: Anumeric
vector with the latitude values of the postal codes.longitude
: Anumeric
vector with the longitude values of the postal codes.
Details
The source of the data will depend on the method used. Run
?tidygeocoder::geo
to learn more. The only
exception is the "qualocep"
and "viacep"
method. These methods will
return the address data from the Qual o CEP
database and the ViaCEP API, respectively.
See ?tidygeocoder::geo
to learn how to use
method = "google
.
See also
Other API functions:
get_qualocep_data()
Examples
if (FALSE) { # \dontrun{
library(dplyr)
"01014908" |>
get_brazil_address_by_postal_code(method = "osm") |>
glimpse()
"01014908" |>
get_brazil_address_by_postal_code(method = "google") |>
glimpse()
"01014908" |>
get_brazil_address_by_postal_code(method = "qualocep") |>
glimpse()
"01014908" |>
get_brazil_address_by_postal_code(method = "viacep") |>
glimpse()
c("01014-908", NA, "05650-905") |>
get_brazil_address_by_postal_code(method = "qualocep") |>
glimpse()
} # }