thin_points {GeoThinneR} | R Documentation |
Spatial Thinning of Points
Description
This function performs spatial thinning of geographic points to reduce point density while maintaining spatial representation. Points are thinned based on a specified distance, grid, or precision, and multiple trials can be performed to identify the best thinned dataset.
Usage
thin_points(
data,
long_col = NULL,
lat_col = NULL,
group_col = NULL,
method = c("brute_force", "kd_tree", "round_hash", "grid", "precision"),
trials = 10,
all_trials = FALSE,
target_points = NULL,
seed = NULL,
verbose = FALSE,
...
)
Arguments
data |
A data frame or tibble containing the points to thin. Must contain longitude and latitude columns. |
long_col |
Name of the column with longitude coordinates (default: "decimalLongitude"). |
lat_col |
Name of the column with latitude coordinates (default: "decimalLatitude"). |
group_col |
Name of the column for grouping points (e.g., species name, year). If NULL, no grouping is applied. |
method |
Thinning method to use 'c("brute_force", "kd_tree", "round_hash", "grid", "precision")'. |
trials |
Number of thinning iterations to perform (default: 10). |
all_trials |
If TRUE, returns results of all attempts; if FALSE, returns the best attempt with the most points retained (default: FALSE). |
target_points |
Optional; a numeric value specifying the exact number of points to keep. If NULL (default), maximizes the number of kept points. |
seed |
Optional; an integer seed for reproducibility of results. |
verbose |
If TRUE, prints progress messages (default: FALSE). |
... |
Additional parameters passed to specific thinning methods (e.g., thin_dist, precision, resolution, origin, R). |
Details
The thinning methods available are: - 'brute_force': Uses a brute force approach to thin points. - 'kd_tree': Uses K-D trees for thinning. - 'round_hash': Uses rounding and hashing for efficient thinning. - 'grid': Applies a grid-based thinning method. - 'precision': Utilizes precision-based thinning.
For more information on specific thinning methods and inputs, refer to their respective documentation: - 'brute_force_thinning()' - 'grid_thinning()' - 'kd_tree_thinning()' - 'rounding_hashing_thinning()' - 'precision_thinning()'
Value
A tibble of thinned points, or a combined result of all attempts if 'all_trials' is TRUE.
Examples
# Generate sample data
set.seed(123)
sample_data <- data.frame(
decimalLongitude = runif(100, -180, 180),
decimalLatitude = runif(100, -90, 90)
)
# Perform thinning using K-D tree method
thinned_data <- thin_points(sample_data,
long_col = "decimalLongitude",
lat_col = "decimalLatitude",
method = "kd_tree",
trials = 5,
verbose = TRUE)
# Perform thinning with grouping
sample_data$species <- sample(c("species_A", "species_B"), 100, replace = TRUE)
thinned_grouped_data <- thin_points(sample_data,
long_col = "decimalLongitude",
lat_col = "decimalLatitude",
group_col = "species",
method = "kd_tree",
trials = 10)