This function crops and extends raster layers to a study area extent (bbox) defined by longitude and latitude then applies a mask based on a provided spatial polygon to remove areas outside the polygon.
layer_mask(layers, study_area)
A `SpatRaster` object representing the masked raster layers.
A stack of raster layers (`SpatRaster` object) to be processed.
A spatial polygon (`sf` object) used to mask the raster layers.