Skip to contents

uncertainty_environment() decides whether an imprecise record is usable (keep or drop). The stronger alternative is to propagate the uncertainty: fit the model once per replicate dataset in which every record is placed at a random position within its own uncertainty radius, and look at how much the predictions vary. Models built from positionally uncertain records can remain ecologically interpretable: in simulations, positional error lowered predictive performance more than it changed variable importance and response shapes, especially for spatially homogeneous predictors (Gabor et al. 2023). Placement within the radius can also be optimised against model performance (Wu et al. 2026); that needs the model and is left to the modelling software.

Usage

jitter_uncertainty(
  points,
  env = NULL,
  n = 10,
  uncertainty = NULL,
  na_uncertainty = NA,
  max_radius_km = 50,
  m = NULL,
  land = NULL,
  require_values = TRUE,
  propagate = c("all", "variable"),
  max_rel = 0.1,
  breadth_probs = c(0.05, 0.95),
  max_tries = 100,
  coords = NULL,
  points_crs = "EPSG:4326",
  seed = NULL,
  verbose = TRUE
)

Arguments

points

Records: a data.frame, CSV path, sf or terra::SpatVector, or the result of uncertainty_environment() (its unc_m is then used).

env

Optional predictor layers (terra::SpatRaster or files), for the require_values constraint and the summary.

n

Number of replicate datasets.

uncertainty

Coordinate uncertainty in metres: a column name (default: unc_m, coordinateUncertaintyInMeters or uncertainty), one value per record, or a single value.

na_uncertainty

Radius (m) for records without an uncertainty; NA (default) keeps them fixed.

max_radius_km

Records with a larger radius are not moved (they are reported; drop them or decide yourself).

m

Optional accessible area: polygons (sf, SpatVector, path) or an m_area from delimit_m(); jittered points must fall inside.

land

Optional land polygons or a raster (cells other than NA and 0 are land); jittered points must fall on land.

require_values

Jittered points must fall in cells with values in every layer of env.

propagate

"all" (default) moves every record with an uncertainty; "variable" only those whose environment varies within the radius by uncertainty_environment() (needs env).

max_rel, breadth_probs

As in uncertainty_environment().

max_tries

Draws per record and replicate before giving up.

coords, points_crs

Coordinate columns and their CRS.

seed

Optional random seed.

verbose

Print progress.

Value

An object of class jittered_records: replicates (a list of n data.frames, each the records with jittered coordinates in the original coordinate columns, lon_orig, lat_orig, record (row of the input), replicate, jitter_m, moved and jitter_failed), records (one row per record: unc_m, moved, failures, and with env the relative range of each layer over the replicates, rel_range_max, its limiting layer and varies), variables (per layer: median and 90th percentile of the relative range, share of records above max_rel), breadth and settings. Loop over x$replicates to fit one model per replicate, then summarise the predictions with coordinate_spread().

Details

Placement. Each record is moved to a point drawn uniformly over the area of its uncertainty circle (distance R * sqrt(u), random direction). With m, land and require_values, points outside M, off land or in cells without values in every layer of env are drawn again (up to max_tries times, as Gabor et al. 2023 re-drew points shifted outside the study area); a record with no valid position stays where it was (jitter_failed). Records with an uncertainty of 0 do not move; records without one move by na_uncertainty metres, or stay fixed when it is NA.

Is it worth it? For each record, the range of each layer over the replicates is divided by the species' niche breadth on that layer (the distance between the breadth_probs quantiles of the values at the records), the same scale as uncertainty_environment(). Records whose environment changes by more than max_rel of the breadth are the ones that make propagating worth the extra model runs; when there are almost none, the replicates are environmentally the same dataset.

Link with uncertainty_environment(). Both measure how much the predictors vary within a record's uncertainty, one analytically (every cell the circle touches), one by sampling. propagate = "variable" uses the analytical check to move only the records whose environment varies (unc_ok = FALSE), keeping environmentally uniform records fixed, so that the replicates differ only where it matters; with uncertainty_environment() the workflow becomes keep (uniform), propagate (variable) or drop (radius above max_radius_km).

Assumptions and limits. Positions are drawn uniformly within the radius, which assumes the radius is a true bound and every position in it equally likely; uncertainty fields in GBIF are often missing or default values. Records without an uncertainty stay where they are (or get na_uncertainty), so their positional error is not propagated.

References

Gabor, L., Jetz, W., Zarzo-Arias, A., Winner, K., Yanco, S., Pinkert, S., Marsh, C.J., Rogan, M.S., Makinen, J., Rocchini, D., Bartak, V., Malavasi, M., Balej, P., Moudry, V. (2023) Species distribution models affected by positional uncertainty in species occurrences can still be ecologically interpretable. Ecography 2023, e06358. doi:10.1111/ecog.06358

Wu, H., Liu, Y., Wu, Z., Abulike, K., Wang, J. (2026) A simulated annealing optimization framework to reduce positional uncertainty and improve performance of species distribution models. Environmental Modelling & Software 204, 107096. doi:10.1016/j.envsoft.2026.107096

Examples

sim <- simulate_enm_data(seed = 1, n_presence = 60)
occ <- sim$presence
occ$coordinateUncertaintyInMeters <- rep(c(0, 2000, 20000), 20)
j <- jitter_uncertainty(occ, sim$env, n = 5, seed = 1)
#> Jittering 40 of 60 records in 5 replicate(s)
j
#> Jittered records: 60 records x 5 replicate(s); 40 moved within their uncertainty
#> 
#> IN SHORT
#> - 0 of the 40 moved records (0%) change their environment by more than 0.1
#>   of the niche breadth on at least one layer across the replicates. The
#>   replicates are environmentally almost the same dataset: propagating is
#>   unlikely to be worth the extra model runs.
#> - Only 5 replicates: the ranges are underestimated; use 10 or more for the
#>   models.
#> - Not moved: fixed: uncertainty 0 (20).
#> 
#>  layer breadth median_rel_range q90_rel_range share_above
#>   env1   0.688           0.0182        0.0563           0
#>   env2   0.718           0.0232        0.0696           0
#> 
#> Points are drawn uniformly over the area of each record's uncertainty
#> circle, re-drawn until they satisfy the constraints (values). rel_range =
#> range of a layer at a record over the replicates (and its original
#> position) / the niche breadth on that layer (5-95% quantiles at the
#> records), as in uncertainty_environment(); share_above = share of moved
#> records above 0.1. The limits of 5% and 25% of records in the advice are
#> preENM defaults, not from the literature. Gabor et al. (2023) found that
#> positional error lowered model performance more than it changed variable
#> importance and response shapes.
head(j$replicates[[1]])
#>        lon      lat coordinateUncertaintyInMeters lon_orig lat_orig record
#> 1 23.93086 50.99900                             0 23.93086 50.99900      1
#> 2 17.83074 50.59473                          2000 17.83234 50.58553      2
#> 3 15.72108 53.07551                         20000 15.68547 52.96804      3
#> 4 17.99137 51.13467                             0 17.99137 51.13467      4
#> 5 16.55384 50.40367                          2000 16.57506 50.40511      5
#> 6 18.55758 53.97124                         20000 18.59202 53.80124      6
#>   replicate  jitter_m moved jitter_failed
#> 1         1     0.000 FALSE         FALSE
#> 2         1  1030.551  TRUE         FALSE
#> 3         1 12200.392  TRUE         FALSE
#> 4         1     0.000 FALSE         FALSE
#> 5         1  1513.742  TRUE         FALSE
#> 6         1 19059.987  TRUE         FALSE
plot_jitter(j)

# \donttest{
# fit one model per replicate in your software, e.g.
# for (d in j$replicates) fit_and_predict(d)
# }