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 or count data, H3 addresses, and environmental predictors. The geometry must be of typeMULTIPOLYGON.- response_col
characterName of the column to use as the outcome (response variable). Default"presence"for presence/absence models. Use"count"when working with count data generated byh3sdm_count_from_records().
Details
This function prepares spatial H3 grid data for species distribution modeling:
Extracts centroid coordinates (
xandy) from MULTIPOLYGON geometries.Removes the geometry column to create a purely tabular dataset for tidymodels.
Assigns roles to columns:
response_col→"outcome"(target variable)h3_address→"id"(used for joining predictions later)xandy→"spatial_predictor"
All other columns are assigned
"predictor"role.