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.
Arguments
- data
An
sf
object, typically the output ofh3sdm_data()
, including species presence-absence, H3 addresses, and environmental predictors. The geometry must be of typeMULTIPOLYGON
.
Details
This function performs key data preparation steps for spatial species distribution modeling:
Extracts centroid coordinates (
x
andy
) 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
andy
→"spatial_predictor"
All other columns are assigned
"predictor"
role.