Prepares an sf object with H3 hexagonal data for modeling with the
tidymodels ecosystem. Extracts centroid coordinates, assigns appropriate
roles to the variables automatically, and returns a ready-to-use recipe for
modeling species distributions.
Arguments
- data
An
sfobject, typically the output ofh3sdm_data(), including species presence-absence, H3 addresses, and environmental predictors. The geometry must be of typeMULTIPOLYGON.
Details
This function prepares spatial H3 grid data for species distribution modeling:
Extracts centroid coordinates (
xandy) from MULTIPOLYGON geometries using sf functions.Removes the geometry column to create a purely tabular dataset for tidymodels.
Assigns roles to columns:
presence→"outcome"(target variable)h3_address→"id"(used for joining predictions later)xandy→"spatial_predictor"
All other columns are assigned
"predictor"role.