Build an empty raster covering the combined extent of one or more spatial objects. Useful for defining the common grid before rasterizing species ranges and fishery footprints.
Examples
# Two features in different places: the grid has to cover both.
a <- terra::vect("POLYGON ((0 0, 2 0, 2 2, 0 2, 0 0))", crs = "EPSG:4326")
b <- terra::vect("POLYGON ((3 3, 5 3, 5 5, 3 5, 3 3))", crs = "EPSG:4326")
grid <- create_study_raster(list(a, b), res = 0.5)
terra::ext(grid)
#> SpatExtent : 0, 5, 0, 5 (xmin, xmax, ymin, ymax)
dim(grid) # rows, columns, layers
#> [1] 10 10 1
terra::hasValues(grid) # FALSE: the grid is empty, it only defines geometry
#> [1] FALSE
# Inputs are projected to `crs` before their extents are combined, so a list
# mixing coordinate systems is fine.
create_study_raster(list(a, terra::project(b, "EPSG:3857")), res = 0.5)
#> class : SpatRaster
#> size : 10, 10, 1 (nrow, ncol, nlyr)
#> resolution : 0.5, 0.5 (x, y)
#> extent : 0, 5, 0, 5 (xmin, xmax, ymin, ymax)
#> coord. ref. : lon/lat WGS 84 (EPSG:4326)