# 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)
Run the code above in your browser using DataLab