Skip to contents

Point thinning based on user-defined distances in geographic or environmental space.

Usage

point_thinning(data, x_column, y_column, thinning_distance, space,
               max_n_samples = 1, replicates = 10, set_seed = 1)

Arguments

data

matrix or data.frame that contains at least two columns.

x_column

(character) the name of the x-axis.

y_column

(character) the name of the y-axis.

thinning_distance

(numeric) distance for thinning. Units must be selected according to the space, kilometers (km) for geographic and Euclidean distances for environmental space.

space

(character) space in which the thinning will be performed. There are two options available: "G", if it will be in geographic space, and "E", if it will be in environmental space.

max_n_samples

(numeric) maximum number of samples to chose with most points included. Default = 1.

replicates

(numeric) number of thinning replicates. Default = 10.

set_seed

(numeric) integer value to specify a initial seed. Default = 1.

Value

A list with one or more elements, depending on max_n_samples. Each element is a data.frame containing points retained after thinning. All elements are different in at least one of the selected points.

Examples

# Data
m_matrix <- read_master(system.file("extdata/m_matrix.rds",
                                    package = "biosurvey"))
data1 <- m_matrix$data_matrix

# Thinning the points
thin <- point_thinning(data1, x_column = "Longitude", y_column = "Latitude",
                       thinning_distance = 200, space = "G",
                       max_n_samples = 1, replicates = 5, set_seed = 1)