Nothing
#' Download spatial data of official metropolitan areas in Brazil
#'
#' @description
#' The function returns the shapes of municipalities grouped by their respective
#' metro areas. Metropolitan areas are created by each state in Brazil. The data
#' set includes the municipalities that belong to all metropolitan areas in the
#' country according to state legislation in each year. Original data were
#' generated by the Brazilian Institute of Geography and Statistics (IBGE). Data
#' at scale 1:250,000, using Geodetic reference system "SIRGAS2000" and CRS(4674).
#'
#' @template year
#' @template code_state
#' @template simplified
#' @template output
#' @template showProgress
#' @template cache
#' @template verbose
#'
#' @return An `"sf" "data.frame"` OR an `ArrowObject`
#'
#' @export
#'
#' @examplesIf identical(tolower(Sys.getenv("NOT_CRAN")), "true")
#' # Read all official metropolitan areas for a given year
#' m <- read_metro_area(year = 1970)
#'
#' m <- read_metro_area(
#' year = 2024,
#' code_state = "RJ"
#' )
#'
read_metro_area <- function(year,
code_state = "all",
simplified = TRUE,
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE){
# Get metadata
temp_meta <- select_metadata(
geography = "metroarea",
year = year,
simplified = simplified,
verbose = verbose
)
# check if download failed
if (is.null(temp_meta)) { return(invisible(NULL)) }
# download file and open arrow dataset
temp_arrw <- download_parquet(
filename_to_download = temp_meta$file_name,
showProgress = showProgress,
cache = cache
)
# check if download failed
if (is.null(temp_arrw)) { return(invisible(NULL)) }
# FILTER
temp_arrw <- filter_arrw(temp_arrw, code = code_state)
# convert to sf
temp <- convert_output(temp_arrw, output)
return(temp)
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.