Skip to contents

This function thins species occurrence records by finding all occupied cells in a 2D environmental grid and returning a single new point at the exact center of each of those cells. This is a deterministic method.

Usage

thin_env_center(data, env_vars, grid_resolution)

Arguments

data

A data.frame containing species occurrence coordinates and the environmental variables.

env_vars

A character vector specifying the column names in data that represent the environmental variables to be used in the analysis.

grid_resolution

A numeric vector of length one or two specifying the resolution(s) for the grid axes. If length one, it is used for both axes.

Value

An object of class bean_thinned_center. which is a list containing:

thinned_points

A data.frame with two columns representing the new points at the center of each occupied environmental grid cell.

n_original

An integer representing the number of complete occurrence records in the input data.

n_thinned

An integer representing the number of unique grid cells that were occupied, which is also the number of points returned.

parameters

A list of the key parameters used, such as whether scaling was applied.

Examples

env_data <- data.frame(
  BIO1  = c(0.1, 0.2, 1.1, 1.2, 1.3),
  BIO12 = c(0.1, 0.2, 2.1, 2.2, 2.3)
)
thin_env_center(env_data, env_vars = c("BIO1", "BIO12"),
                grid_resolution = c(0.1, 0.2))
#> --- Bean Deterministic Thinning Results ---
#> 
#> Thinned 5 original points to 5 unique grid cell centers.
#> This represents a retention of 100.0% of the data.
#> 
#> --------------------------------------