Skip to content

Prepares an sf object with H3 hexagonal data for modeling with the tidymodels ecosystem. Extracts centroid coordinates and assigns appropriate roles to the variables automatically.

Usage

h3sdm_recipe(data)

Arguments

data

An sf object, typically the output of h3sdm_data(), including species presence-absence, H3 addresses, and environmental predictors. The geometry must be of type MULTIPOLYGON.

Value

A tidymodels recipe object (class "h3sdm_recipe") ready for modeling.

Details

This function performs key data preparation steps for spatial species distribution modeling:

  • Extracts centroid coordinates (x and y) from polygon geometries.

  • Removes the geometry column, as tidymodels works with tabular data.

  • Assigns roles to columns:

    • presence"outcome" (target variable)

    • h3_address"id" (kept for joining with predictions)

    • x and y"spatial_predictor"

  • All other columns are assigned "predictor" role.

Examples

if (FALSE) { # \dontrun{
# Assuming `combined_data` is an sf object from h3sdm_data()
sdm_recipe <- h3sdm_recipe(combined_data)
sdm_recipe  # inspect the recipe
} # }