Spatial thinning in geographic space, the most widely used correction
for clustered records: records are removed until no two kept records
lie within dist_km of each other. As in spThin (Aiello-Lammens et al.
2015), the record with the most neighbours within dist_km is removed
first (ties at random), which keeps more records than removing them in
random order. The solution depends on the random tie-breaks, so the
thinning is repeated n_rep times: the run that keeps the most records
is returned (as in spThin), and all runs are kept in replicates, so
that a model can be fitted to several and the spread of the predictions
compared, e.g. with coordinate_spread().
Usage
thin_distance(
points,
dist_km,
n_rep = 10,
seed = 1,
coords = NULL,
points_crs = "EPSG:4326"
)Arguments
- points
Records: a data.frame with coordinates, an
sfobject or a terra::SpatVector.- dist_km
Minimum distance (km) between kept records.
- n_rep
Number of thinning runs.
- seed
Seed for the tie-breaks (
NULLfor none).- coords, points_crs
Coordinate columns and their CRS when
pointsis a table.
Value
An object of class distance_thinning: data (the records with
a logical column kept, from the run that keeps the most),
replicates (a list of the row numbers kept in each run), summary
(records kept per run) and settings.
Details
Status, assumptions and limits. An established method
(Aiello-Lammens et al. 2015). Distances are great-circle (chord)
distances for longitude/latitude and Euclidean in projected
coordinates. Thinning by distance evens out records in geographic, not
environmental, space: it may remove the records of rare conditions and
of the limits of the niche (in the simulations of validation/, 7-25%
of the records holding the minimum or maximum of a variable), which
thin_environment() keeps by design. Whether thinning improves models
is debated (Ten Caten & Dallas 2023; Lamboley & Fourcade 2024), and no
distance is best in general.
What to vary. dist_km (e.g. the grain of the predictors, and two to
five times it), compared with other designs in bias_sensitivity();
n_rep and the spread among replicates.
References
Aiello-Lammens, M.E., Boria, R.A., Radosavljevic, A., Vilela, B., Anderson, R.P. (2015) spThin: an R package for spatial thinning of species occurrence records for use in ecological niche models. Ecography 38, 541-545. doi:10.1111/ecog.01132
Ten Caten, C., Dallas, T. (2023) Thinning occurrence points does not improve species distribution model performance. Ecosphere 14, e4703. doi:10.1002/ecs2.4703
Lamboley, Q., Fourcade, Y. (2024) No optimal spatial filtering distance for mitigating sampling bias in ecological niche models. Journal of Biogeography 51, 1783-1794. doi:10.1111/jbi.14854
Examples
sim <- simulate_enm_data(seed = 1, n_presence = 150)
th <- thin_distance(sim$presence, dist_km = 20, n_rep = 5)
th
#> Thinning by distance: 150 records, 20 km, 5 run(s)
#>
#> IN SHORT
#> - Kept 125 of 150 records (83%) so that no two are closer than 20 km.
#> - The 5 runs kept 125 to 125 records and gave 5 different set(s) of
#> records; `replicates` holds them all, to fit a model to several and
#> compare the predictions.
#>
#> The record with the most neighbours within the distance is removed first, ties at
#> random (Aiello-Lammens et al. 2015); the run that keeps the most records is
#> returned.
#>
#> A preENM sensitivity analysis: how much the result depends on which records
#> survive thinning. The others are listed in ?sensitivity_analyses.
kept <- th$data[th$data$kept, ]
