Skip to content

Generates an H3 hexagonal grid over a specified area of interest (AOI) and extracts numeric, categorical, and landscape predictors for each hexagon. Uses functions from the 'paisaje' package to calculate landscape metrics when landscape_raster is provided. If landscape_raster is not supplied, only numeric and categorical predictors will be extracted.

Usage

h3sdm_predictors(
  aoi_sf,
  res = 6,
  num_rasters = NULL,
  cat_rasters = NULL,
  landscape_raster = NULL,
  expand_factor = 0.1
)

Arguments

aoi_sf

An sf object (POLYGON or MULTIPOLYGON) defining the area of interest.

res

Integer. H3 resolution (default = 6).

num_rasters

A SpatRaster or list of SpatRasters with numeric variables to extract (optional).

cat_rasters

A named list of SpatRasters with categorical variables to extract (optional).

landscape_raster

A SpatRaster for calculating landscape metrics (optional).

expand_factor

Numeric. Factor to expand the AOI when creating the H3 grid (default = 0.1).

Value

An sf object (MULTIPOLYGON) representing the H3 grid, with predictor columns added.

Examples

if (FALSE) { # \dontrun{
# Example: Extract numeric and categorical predictors for a study area
library(terra)
library(sf)

bio <- rast("cr_bio/bio.tif")           # numeric raster
lc  <- rast("landcover.tif")            # categorical raster
cr  <- cr_outline_c                      # area of interest (sf POLYGON/MULTIPOLYGON)

pred_sf <- h3sdm_predictors(
  aoi_sf = cr,
  res = 6,
  num_rasters = bio,
  cat_rasters = list(landcover = lc)
)
} # }