Nothing
#' Download spatial data of disaster risk areas
#'
#' @description
#' This function reads the the official data of disaster risk areas in Brazil
#' (currently only available for 2010). It specifically focuses on geodynamic
#' and hydro-meteorological disasters capable of triggering landslides and floods.
#' The data set covers the whole country. Each risk area polygon (known as 'BATER')
#' has unique code id (column 'geo_bater'). The data set brings information on
#' the extent to which the risk area polygons overlap with census tracts and block
#' faces (column "acuracia") and number of ris areas within each risk area (column
#' 'num'). Original data were generated by IBGE and CEMADEN. For more information
#' about the methodology, see deails at \url{https://www.ibge.gov.br/geociencias/organizacao-do-territorio/tipologias-do-territorio/21538-populacao-em-areas-de-risco-no-brasil.html}
#'
#' @template year
#' @template code_muni
#' @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 disaster risk areas in an specific year
#' d <- read_disaster_risk_area(year = 2010)
#'
#' # Read disaster risk areas in a given municipality
#' d <- read_disaster_risk_area(year = 2010, code_muni = 2927408)
#'
#' # Read disaster risk areas in a given state
#' d <- read_disaster_risk_area(year = 2010, code_muni = "AC")
read_disaster_risk_area <- function(year,
code_muni = "all",
simplified = TRUE,
output = "sf",
showProgress = TRUE,
cache = TRUE,
verbose = TRUE){
# Get metadata
temp_meta <- select_metadata(
geography="disasterriskareas",
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_muni)
# 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.