Skip to contents

Helper function to scale a target layer in a region of interest. Can be used to compare locations with eval_pt() and eval_buffer(), and select locations based off of relative values instead of absolute values.

Usage

scale_layer(target, region, center = TRUE, scale = TRUE)

Arguments

target

SpatRaster target (see terra::rast())

region

object which can be passed to terra::ext() including sf, SpatRaster, and 2x2 matrices.

center

see terra::scale()

scale

see terra::scale()

Value

SpatRaster layer, cropped to extent of provided region, and scaled.

See also

Examples

# Load packages
library(terra)

# Load data
data("clearwater_lake_hydro")
clearwater_elev_path <- system.file(
  "extdata", "clearwater_lake_elevation.tif", package = "camtrapmonitoring")
clearwater_lake_elevation <- rast(clearwater_elev_path)

# Region of interest around Clearwater lake
roi <- clearwater_lake_hydro[4,]

# Scale elevation in extent of density grid
elev_scaled <- scale_layer(target = clearwater_lake_elevation, region = roi)