extract_covars: Extract covariate values from a set of rasters

View source: R/extract_covars.R

extract_covarsR Documentation

Extract covariate values from a set of rasters

Description

Extract covariate values from a set of rasters

Usage

extract_covars(locations, raster_list)

Arguments

locations

a data frame of (x,y) locations with names "x" and "y".

raster_list

a list of raster objects.

Value

a matrix of covariates drawn from the provided rasters.

Examples

# Load example raster data
raster_paths <- list.files(system.file("extdata", package = "ldmppr"),
  pattern = "\\.tif$", full.names = TRUE
)
rasters <- lapply(raster_paths, terra::rast)

# Scale the rasters
scaled_raster_list <- scale_rasters(rasters)

# Load example locations
locations <- small_example_data %>%
  dplyr::select(x, y) %>%
  as.matrix()

# Extract covariates
example_covars <- extract_covars(locations, scaled_raster_list)
head(example_covars)


ldmppr documentation built on April 4, 2025, 12:45 a.m.