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.

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{
library(terra)
library(sf)

# Cargar rasters de ejemplo
bio <- rast("cr_bio/bio.tif")           # raster numérico
lc  <- rast("landcover.tif")            # raster categórico
cr  <- cr_outline_c                      # área de interés (sf POLYGON/MULTIPOLYGON)

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