getdata_bc {rasterbc} | R Documentation |
Download data from the rasterbc collection
Description
Downloads all mapsheet layers (geoTIFFs) covering the geographical extent of geo
for the
specified collection
, varname
, and year
. Input geo
can be a vector
of (4-character) NTS/SNRC mapsheet codes or a geometry of class sfc
.
Usage
getdata_bc(
geo = NULL,
collection = NULL,
varname = NULL,
year = NULL,
force.dl = FALSE,
quiet = FALSE
)
Arguments
geo |
vector of character strings (NTS/SNRC codes) or a geometry of class |
collection |
character string indicating the data collection to query |
varname |
character string indicating the layer to query |
year |
integer indicating the year to query (if applicable) |
force.dl |
logical indicating whether to overwrite any existing data |
quiet |
logical, suppresses console messages |
Details
The data files are written to the directory returned by rasterbc::datadir_bc()
. Mapsheets
found there (already downloaded) are not downloaded again unless force.dl==TRUE
. Users
should only need to download a mapsheet once - there are no plans to update the rasterbc
collection in the future.
Value
a vector of character string(s) containing the absolute path(s) to the downloaded file(s)
See Also
findblocks_bc
to identify which mapsheets will be downloaded
listdata_bc
for a list of available collections, variable names, years
Examples
# define a location of interest, and a polygon around it then fetch the corresponding DEM data
input.point = sf::st_point(c(x=-120.1, y=50.1)) |> sf::st_sfc(crs='EPSG:4326')
if( requireNamespace('units', quietly = TRUE) ) {
input.polygon = input.point |> sf::st_buffer(units::set_units(10, km))
## Not run:
# the following downloads data from FRDR
block.path = getdata_bc(input.point, 'dem')
getdata_bc(input.polygon, 'dem')
# load one of the mapsheets
terra::rast(block.path)
## End(Not run)
}