Skip to contents

This function generates a hexagonal grid and performs spatial sampling based on the provided data and parameters.

Usage

spatial_hexgrid_sample(
  data,
  sidelength,
  top_type = "flat",
  show_grid = TRUE,
  fold_selection = "default",
  k = NULL
)

Arguments

data

The input data. It can be either an sf object or a SpatialPoints object.

sidelength

The length of the hexagon's side.

top_type

The type of the hexagon top, either "flat" or "pointy". Default is "flat".

show_grid

Logical value indicating whether to display the hexagonal grid. Default is TRUE.

fold_selection

The method for fold selection. Options include "default", "systematic", or "random". Default is "default".

k

The number of folds for fold selection. Required when 'fold_selection' is "systematic" or "random". Default is NULL.

Value

A list containing the plots (if 'show_grid' is TRUE), the hexagonal blocks (sf object), and the split objects.

Examples

# Load sample data
data(landcover)

# Generate a spatial hexagonal grid sampling with a sidelength of
# 10 km and 5 folds using systematic selection
hexgrid <- spatial_hexgrid_sample(landcover, sidelength = 10000,
            fold_selection = "systematic", k = 5)
#> Warning: attribute variables are assumed to be spatially constant throughout all geometries