Get a WRI raster layer
get_layer.RdRetrieves a hosted WRI raster asset and optionally crops it to a spatial
area of interest. The area of interest can be supplied in several formats:
a numeric bounding box, a file path to a shapefile or GeoJSON, an
sf object, or a terra spatial object
(SpatVector, SpatRaster, or SpatExtent).
Arguments
- id
Character. Layer id to retrieve. See
wri_overview_dffor available ids.- aoi
Area of interest used to crop the layer. Accepted inputs:
NULL— returns the full global layer (default).Numeric vector
c(xmin, ymin, xmax, ymax)— bounding box;aoi_crsis required.Character path to a shapefile (
.shp) or GeoJSON file.An
sforsfcobject.A
terra::SpatVector,terra::SpatRaster, orterra::SpatExtent.
- aoi_crs
Character or integer CRS specification (e.g.
"EPSG:4326"or4326). Required whenaoiis a numeric bounding box or a CRS-less spatial object; must be omitted whenaoialready carries a CRS.
Value
A terra::SpatRaster cropped to aoi, or the full
layer when aoi = NULL.
Examples
if (FALSE) { # \dontrun{
# Full layer
wri <- get_layer("WRI_score")
# Numeric bbox (WGS 84)
wri_norcal <- get_layer("WRI_score",
aoi = c(-122, 37, -121, 38),
aoi_crs = "EPSG:4326")
# Shapefile path
shp <- system.file("demos/data/Eaton_Perimeter_20250121.shp",
package = "firex")
wri_eaton <- get_layer("WRI_score", aoi = shp)
} # }