Reads MTBS fire data from a local MTBS ZIP downloaded with
get_mtbs() and returns either a spatial object or a plain attribute table.
Arguments
- dataset
character(1)which dataset to read. Use"perimeters"(default) to read fire perimeters as polygons, or"occurrence"to read fire centroids as points.- years
integervector of years to keep. Accepts a single year (2020), a contiguous range created with:notation (2010:2023), or a vector of specific years (c(2000, 2010, 2020)). Only fires whose ignition year appears inyearsare returned.NULL(the default) returns all years without filtering.- type
charactervector of incident types to keep, matched against theIncid_Typecolumn. Valid values are"Wildfire","Prescribed Fire","Unknown", and"Wildland Fire Use".NULL(the default) returns all incident types.- geometry
logical(1)WhenTRUE(the default) the result is a spatial object (sforterra::SpatVectordepending onoutput). WhenFALSEthe shapefile attributes are returned as a plaindata.framewith the geometry column dropped.- output
character(1)The class of the returned spatial object. Either"vect"/"terra"(default) for aterra::SpatVector, or"sf"for ansfobject. Ignored whengeometry = FALSE. Note this default ("vect") intentionally differs from the ecoregion loaders (get_nal1eco, etc.), which default to"sf"; passoutputexplicitly for a consistent object class across functions.- cache
logical(1)orcharacter(1). Controls whereread_mtbs()looks for the downloaded ZIP file. WhenFALSE(the default), the current working directory is used (it does not mean caching is disabled, just that it looks in the local folder). WhenTRUE, the platform user cache directory (tools::R_user_dir("fireR", "cache")) is used. Supply a directory path as a string to specify a custom location.- verbose
logical(1)print progress messages.
Value
A
terra::SpatVectorwhenoutput = "vect"/"terra"andgeometry = TRUE.An
sfobject whenoutput = "sf"andgeometry = TRUE.A
data.framewhengeometry = FALSE.
Details
read_mtbs() does not download data. Use get_mtbs() first to obtain the
data ZIP archive.
Examples
if (FALSE) { # \dontrun{
zip_path <- get_mtbs()
fires <- read_mtbs(output = "sf")
# Single year
fires_2020 <- read_mtbs(years = 2020, output = "sf")
# Contiguous range
fires_recent <- read_mtbs(years = 2010:2023, output = "sf")
# Specific years only
fires_sel <- read_mtbs(years = c(2000, 2010, 2020), output = "sf")
tbl <- read_mtbs(geometry = FALSE)
} # }