Skip to contents

Overview

GeoThinneR is an R package designed for efficient spatial thinning of species occurrence records and other geospatial point data. It integrates three primary thinning methods (distance-based, grid-based, and precision-based thinning) into a single package, eliminating the need to switch between multiple tools. GeoThinneR implements algorithms based on kd-tree structures for nearest-neighbor searches, significantly improving performance and scalability for large datasets. Additionally, the package provides custom functionalities useful for species distribution modeling (SDM), such as thinning by group (e.g., multiple species), retaining an exact number of points, and prioritizing records based on user-defined variables. These features make GeoThinneR a valuable tool for handling large-scale occurrence datasets.

Not sure which thinning parameter to use? GeoThinneR also offers data-driven thinning parameter estimation based on Ibáñez et al. (2026). The estimate_thinning_parameter() function assesses the stability of cumulative environmental medians: LS-TP selects the largest tested stable resolution, while BD-TP predicts a resolution from geographical range size. Parameter estimation and thinning are separate steps, so the estimated resolution can be applied with thin_points().

GeoThinneR has been developed as an alternative tool for spatial thinning to mitigate the effects of sampling bias in SDM. Various approaches exist to address sampling bias, each suited to different scenarios. Below are some references discussing methods for bias correction and spatial thinning:

  • Boria, R. A., Olson, L. E., Goodman, S. M., & Anderson, R. P. (2014). Spatial filtering to reduce sampling bias can improve the performance of ecological niche models. Ecological modelling, 275, 73-77. https://doi.org/10.1016/j.ecolmodel.2013.12.012
  • Veloz, S. D. (2009). Spatially autocorrelated sampling falsely inflates measures of accuracy for presence‐only niche models. Journal of biogeography, 36(12), 2290-2299.https://doi.org/10.1111/j.1365-2699.2009.02174.x
  • Moudrý, V., Bazzichetto, M., Remelgado, R., Devillers, R., Lenoir, J., Mateo, R.G., Lembrechts, J.J., Sillero, N., Lecours, V., Cord, A.F., Barták, V., Balej, P., Rocchini, D., Torresani, M., Arenas-Castro, S., Man, M., Prajzlerová, D., Gdulová, K., Prošek, J., Marchetto, E., Zarzo-Arias, A., Gábor, L., Leroy, F., Martini, M., Malavasi, M., Cazzolla Gatti, R., Wild, J. and Šímová, P. (2024), Optimising occurrence data in species distribution models: sample size, positional uncertainty, and sampling bias matter. Ecography, 2024: e07294. https://doi.org/10.1111/ecog.07294

Getting started

You can install GeoThinneR from CRAN with:

install.packages("GeoThinneR")

To install the development version from GitHub, use:

# install.packages("devtools")
devtools::install_github("jmestret/GeoThinneR")

Using GeoThinneR is simple. The main function, thin_points() applies spatial thinning using a user-specified method and thinning constraint. In the examples below, data represents an occurrence data frame with longitude and latitude columns.

library(GeoThinneR)

# Distance-based thinning (minimum separation of 10 km)
thin_points(data, method = "distance", thin_dist = 10)

# Grid-based thinning (grid resolution of 0.1 degrees)
thin_points(data, method = "grid", resolution = 0.1)

# Precision-based thinning (rounding coordinates to 1 decimal place)
thin_points(data, method = "precision", precision = 1)

Instead of selecting a grid resolution arbitrarily, you can estimate one using the stability of an environmental variable. For example, with occurrence data containing lon, lat, species, and temperature columns:

ls_fit <- estimate_thinning_parameter(
  data,
  group_col = "species",
  env_col = "temperature",
  param_method = "ls-tp",
  seed = 123
)

ls_fit$estimated_parameters

# Check whether a stable resolution was identified
ls_fit$estimates[, c("group", "estimated_parameter", "selection_status")]

# Apply the estimate for one species with thin_points()
thinned <- thin_points(
  subset(data, species == "sp1"),
  method = "grid",
  resolution = unname(ls_fit$estimated_parameters[["sp1"]])
)

Documentation

For detailed documentation, guides, and usage examples, please visit the official package documentation.

Contributing

We welcome contributions! If you have suggestions for improvements or new features, please open an issue or submit a pull request on our GitHub repository.

How to cite GeoThinneR

If you use GeoThinneR in your work, please cite the published article:

Mestre-Tomás, J. (2026). GeoThinneR: An R Package for Efficient Spatial Thinning of Species Occurrences and Point Data. The R Journal, 18(1), 299-314. https://doi.org/10.32614/RJ-2026-006

If you use estimate_thinning_parameter(), please also cite the manuscript describing the thinning-parameter estimation framework:

Ibáñez, H., Bidegain, G., Sáez de Ocáriz, H., Mestre-Tomás, J., Verbruggen, H., Jueterbock, A. O., & Becerro, M. A. (2026). Stop guessing thinning distances: a data-driven framework for spatial thinning parametrization for ecological modelling. bioRxiv, 2026-10. https://doi.org/10.64898/2026.10.23.759308