Download a single interpolated biomass raster by slice ID
Usage
dm_get_raster(
dataset_code,
layer,
year,
out_tif = NULL,
out_sr = NULL,
transform = function(x) x^(1/3),
bbox = NULL,
bbox_sr = NULL,
overwrite = F,
verbose = F
)Arguments
- dataset_code
The DisMAP dataset code (e.g., "AI", "EBS", "GOA"), per
dm_datasets$dataset_code- layer
The layer in the dataset, typically the scientific name of the species or "Species Richness", per
dm_get_dataset_layers(dataset_code)- year
The year of the slice to download, per
dm_get_dataset_layer_years(dataset_code, layer)- out_tif
optional output GeoTIFF path to write raster
- out_sr
optional output spatial reference for output raster; defaults to native spatial reference
- transform
Function to transform raster values (default is cube root): function(x) x^(1/3)
- bbox
optional bounding box coordinates (xmin, ymin, xmax, ymax); defaults to maximum extent
- bbox_sr
optional spatial reference for bounding box; defaults to native spatial reference; you can use geographic (4326)
- overwrite
if out_tif exists, overwrite it (default is FALSE)
- verbose
if TRUE, print additional information
Examples
# get raster for a specific dataset, layer, and year
dataset_code <- "NEUS_SPR"
layer <- "Paralichthys dentatus"
year <- 2015
# download the raster
r <- dm_get_raster(dataset_code, layer, year)
r
#> class : SpatRaster
#> dimensions : 400, 400, 1 (nrow, ncol, nlyr)
#> resolution : 2660, 2660 (x, y)
#> extent : 321350, 1385350, 3888846, 4952846 (xmin, xmax, ymin, ymax)
#> coord. ref. : NAD83(2011) / UTM zone 18N (EPSG:6347)
#> source(s) : memory
#> varname : file35ef2bef7398
#> name : wtcpue
#> min value : 0.000000
#> max value : 3.629863
# alternatively, save to a file
tif_path <- tempfile(fileext = ".tif")
r <- dm_get_raster(dataset_code, layer, year, tif_path)
file.exists(tif_path)
#> [1] TRUE