Skip to contents

Draws the area the species could have reached (the M of the BAM diagram), which defines where background points are drawn and to which the predictors are clipped. Instead of choosing buffer radii by hand, one number is derived from the data: the linking distance L.

Usage

delimit_m(
  points,
  method = c("delaunay", "buffer", "cluster_hull", "convex_hull", "adaptive",
    "simulation", "regions"),
  link_km = NULL,
  link_search = c(100, 600),
  link_fallback = c("stop", "upper"),
  link2_max_km = 1000,
  link_mult = 1,
  buffer_km = NULL,
  adaptive_mult = 1,
  adaptive_weight = FALSE,
  adaptive_min_km = 1,
  env = NULL,
  simulation = list(),
  regions = NULL,
  region_min = 1,
  region_buffer_km = NULL,
  hull_ratio = 1,
  corridors = FALSE,
  closing_km = NULL,
  closing_mode = c("generous", "strict"),
  close_km = 25,
  fill_holes = TRUE,
  add = NULL,
  add_sites = NULL,
  seal_km = 5,
  exclude = NULL,
  extent = NULL,
  land = NULL,
  thin_km = 10,
  group = NULL,
  priority = NULL,
  priority_col = "source",
  crs = "auto",
  coords = NULL,
  points_crs = "EPSG:4326",
  effort = NULL,
  effort_alpha = 0.05,
  effort_min_km = NULL
)

Arguments

points

Occurrence records: a data.frame with coordinates (lon/lat or detected column names), a CSV path, an sf object or a terra::SpatVector. Combine modern and fossil records beforehand if both should shape M (e.g. with merge_occurrences()).

method

"delaunay", "buffer", "cluster_hull", "convex_hull", "adaptive", "simulation" or "regions".

Linking distance L in km; NULL (default) = derived from the data.

Range (km) in which the automatic L is searched.

What to do when fewer than three spanning-tree links fall within link_search, so that no L can be derived: "stop" (default) with an explanation and the longest links, or "upper" to use the upper end of link_search as an explicit fallback. The fallback is marked in the result (L_source = "fallback") and in every printout: it is not an estimate from the records.

Upper limit (km) for the second linking distance L2.

Multiplier of L for the method (sensitivity analyses, e.g. 0.5 or 2).

buffer_km

Buffer radius for method = "buffer" (default L/2).

adaptive_mult, adaptive_weight, adaptive_min_km

For "adaptive": multiplier of the cluster radii, scaling by cluster size, and the radius (km) of single-record clusters.

env, simulation

For "simulation": the predictor layers and a list of further arguments for m_simulate().

regions, region_min, region_buffer_km

For "regions": polygons (sf, terra::SpatVector or a path, any CRS), the fewest records a region must hold to be included, and an optional buffer radius (km) around the records to which the regions are cut.

hull_ratio

For "cluster_hull": 1 = convex, smaller = more concave (needs GEOS >= 3.11).

corridors

Join clusters lying within L2 of each other by corridors.

closing_km

Closing radius (km). Default: L/2 for "delaunay" (or L2/2 with corridors), 0 otherwise.

closing_mode

"generous" (default): the closing works on M as a whole, so it also bridges separate clusters whose buffers lie less than twice closing_km apart (with the default closing of L/2, records up to about 2L apart end up in one patch), including in M area that may have been accessible but is not shown by the records. "strict": each separate part is closed on its own, so the patches of M are the clusters linked at L (and corridors); use it when other evidence says that clusters farther apart than L are separate.

close_km

Small closing (km) applied to the raw buffers to smooth them (default 25).

fill_holes

Fill interior holes.

add

Expert polygons to add (sf, terra::SpatVector or a path, any CRS).

add_sites

Expert sites to add: a data.frame with lon, lat and buffer_km (and optionally name).

seal_km

Closing (km) after the additions, sealing slivers where an added polygon almost touches the automatic M.

exclude

Polygons to remove from M (e.g. another mountain system). Records inside them are dropped before M is built.

extent

Optional c(xmin, xmax, ymin, ymax) in longitude/latitude: records outside are dropped and M is clipped to it.

land

Optional land polygons to trim the sea from M. Not needed for clipping rasters, whose sea cells are usually NA anyway.

thin_km

Thinning cell size (km) before linking; one record per cell (and per group).

group

Optional column (e.g. modern / fossil) thinned separately and reported separately.

priority, priority_col

Sources preferred when thinning (see thin_by_cell()).

crs

Equal-area projection used for all geometry. "auto": Lambert azimuthal equal-area centred on the data (polar for circumpolar data).

coords, points_crs

Coordinate columns and their CRS when points is a table.

effort

Optional recording effort: a terra::SpatRaster (or a path) whose first layer gives the effort per cell in any unit, e.g. the records of a target group per cell from gbif_effort_rasters(). With it, each spanning-tree link of at least effort_min_km is tested for crossing a gap that was recorded without finding the species, and a derived L is lowered so that it does not reach across such a gap (see Details).

effort_alpha

The gap is taken as surveyed when the probability of recording no record there, if the species occurred there, is below this value (default 0.05, i.e. about three records expected).

effort_min_km

Shortest link tested (default: the lower end of link_search). Links shorter than a known dispersal distance can be left untested by setting it to that distance.

Value

An object of class m_area: a list with m (the final M, sfc in crs), automatic (before expert additions), corridors, points (thinned records with their cluster), all_points (all records used), linking (see linking_distance()), report and settings. Use plot_m_area(), m_report(), write_m_area() and crop_to_m().

Details

Linking distance. After thinning (one record per thin_km cell), the records are joined by single-linkage clustering, i.e. the minimum spanning tree. Distances between neighbouring records within a continuous range are sampling gaps; the gaps between separate land masses or isolated parts of the range are much longer. L is the last link before the largest relative jump in the sorted spanning-tree links between link_search[1] and link_search[2] km. A second distance L2 is used for corridors: the link just after the largest jump among the links longer than L (up to link2_max_km), or the longest of them when there are only one or two. See linking_distance().

L is a spatial connectivity threshold derived from the records, not an estimate of dispersal distance: it reflects how densely the range was recorded as much as how the species is distributed, and the largest gap need not be a biogeographical barrier (nor every barrier the largest gap). Check its stability with other thin_km and link_search values, and treat the M methods as alternative hypotheses about accessibility, compared with m_scenarios().

Recording effort. A long link may be a sampling gap (nobody looked) or a real gap (people looked and did not find the species). The records alone cannot tell the two apart, so a sparsely recorded range can be joined across a real gap. With effort (e.g. the records of a target group recorded in the same way), each long link is tested: the area along the link farther than the typical spacing of the records (the median link) from every record is the gap, and the number of records expected there is the effort in the gap times the records per unit of effort around the records. If none was recorded although several were expected (Poisson probability of none below effort_alpha), the gap is taken as real: a derived L is lowered to the longest link shorter than the shortest such gap, and no corridor crosses it. A gap that was not recorded remains a possible sampling gap. The records per unit of effort are counted around each link (within five typical spacings, or the link length), so parts of the range recorded at different rates are each judged by their own. The test assumes the species would be recorded per unit of effort in the gap as around the link; where a population is recorded rarely per unit of effort, gaps within it can look real. A gap of unsuitable habitat is real for the records but may still be crossed by dispersal: set effort_min_km somewhat above the distance between records across a gap the species is known to cross (records lie farther apart than the edges of the gap). In simulations (validation/validate_m.R), a recorded gap between populations that sparse records had joined in 40% of runs kept them apart in every run; a gap nobody recorded changed nothing. (A preENM method.)

Several taxa. group thins and reports groups (e.g. modern and fossil records) separately but builds one M. For several species, lineages or cytotypes, build one M per group (call delimit_m() on each subset): individual accessible areas improved stacked models (Cooper & Soberon 2018), and niche comparisons should use each group's own M (niche_overlap() with a list of areas).

Whatever the method, compare it with others in m_scenarios(): the calibration area strongly affects model accuracy (Luna et al. 2024).

Methods (radius r = L/2 by default: two buffers of L/2 touch when records are L apart, so every chain of records linked at L becomes one patch):

  • "delaunay" (default): Delaunay triangles whose edges are all at most L, plus buffers of r around every record. Follows concave range outlines.

  • "buffer": buffers of radius buffer_km (default r) around every record.

  • "cluster_hull": for each cluster of records linked at L, the convex hull (hull_ratio = 1) or a concave hull (hull_ratio < 1) of the buffers. Fills gaps inside each cluster automatically.

  • "convex_hull": one convex hull around all buffers (the simplest and most generous M).

  • "simulation": M simulated by dispersal from the records over the landscape in env (m_simulate(), Machado-Stredel et al. 2021); give its settings in simulation, e.g. simulation = list(kernel_sd = 2, n_events = 30, barrier = mountains). L is still computed and reported but does not shape this M.

  • "regions": the biogeographic units that hold records (Barve et al. 2011): of the polygons in regions (e.g. ecoregions, Dinerstein et al. 2017; biomes; or river basins such as HydroBASINS, Lehner & Grill 2013, for freshwater taxa), those with at least region_min records, optionally intersected with buffers of region_buffer_km around the records (units that are huge relative to the species' dispersal). L is still computed and reported but does not shape this M. A region holding a single stray record is included like any other: raise region_min, or filter the records first.

  • "adaptive": spatially adaptive buffers for unevenly surveyed areas (Barbosa 2026, "cluster mean distance"): around each cluster of records linked at L, a buffer whose radius is the mean distance between the records of that cluster (times adaptive_mult), so well-surveyed, extensive clusters reach further and isolated records keep only a small circle (adaptive_min_km) instead of pulling unsurveyed land into M. With adaptive_weight = TRUE each radius is further scaled by the cluster's number of records relative to the largest cluster. One large, extensive cluster gets a wide buffer (its mean distance can be several times L), so this method is generous for well-surveyed ranges and conservative for scattered records.

Which arguments matter. Every call uses the records and their preparation (points, coords, points_crs, thin_km, group, priority, priority_col, extent, exclude, crs), the linking distance (link_km, link_search, link_fallback, link2_max_km, link_mult, and effort, effort_alpha, effort_min_km to test gaps against recording effort) and the finishing steps below. The others belong to one method:

MethodIts own arguments
"delaunay"(none beyond L)
"buffer"buffer_km
"cluster_hull"hull_ratio
"convex_hull"(none beyond L)
"adaptive"adaptive_mult, adaptive_weight, adaptive_min_km
"simulation"env, simulation
"regions"regions, region_min, region_buffer_km
finishing (all)corridors, closing_km, closing_mode, close_km, fill_holes, add, add_sites, seal_km, land

Steps after the method, in order: corridors between clusters (corridors = TRUE: the spanning-tree links between L and L2, buffered by r), a closing (buffer out and back in by closing_km; fills bays and gaps narrower than twice that, also between clusters unless closing_mode = "strict"), filling of interior holes, the expert additions (add polygons and add_sites), sealing slivers between them (seal_km), filling holes again, and finally clipping to extent, removing exclude and trimming to land.

Expert intervention. Everything automatic can be overridden: set link_km by hand, add polygons drawn in a GIS (e.g. a valley or migration route the automatic M leaves out) with add, add sites known from the literature with add_sites, and remove areas with exclude. The report states how much area each addition contributes, so it can be reported as expert-based in the Methods.

The default ("delaunay", closed by L/2, holes filled) is the M selected for Dryas octopetala in Europe, where L was 340 km.

Status. The linking-distance M is a preENM method; the adaptive buffers follow Barbosa (2026) and the simulation Machado-Stredel et al. (2021).

References

Barbosa, A.M. (2026) Spatially adaptive background delimitation strategies for species distribution models with unevenly surveyed occurrences. Biodiversity Informatics 20, 81-88. doi:10.17161/bi.v20i1.25045

Machado-Stredel, F., Cobos, M.E., Peterson, A.T. (2021) A simulation-based method for selecting calibration areas for ecological niche models and species distribution models. Frontiers of Biogeography 13, e48814. doi:10.21425/F5FBG48814

Luna, S., Pena-Peniche, A., Mendoza-Alfaro, R. (2024) Species distribution model accuracy is strongly influenced by the choice of calibration area. Biodiversity Informatics 18, 43-55. doi:10.17161/bi.v18i.22655

Barve, N., Barve, V., Jimenez-Valverde, A., et al. (2011) The crucial role of the accessible area in ecological niche modeling and species distribution modeling. Ecological Modelling 222, 1810-1819. doi:10.1016/j.ecolmodel.2011.02.011

Cooper, J.C., Soberon, J. (2018) Creating individual accessible area hypotheses improves stacked species distribution model performance. Global Ecology and Biogeography 27, 156-165. doi:10.1111/geb.12678

Dinerstein, E., Olson, D., Joshi, A., et al. (2017) An ecoregion-based approach to protecting half the terrestrial realm. BioScience 67, 534-545. doi:10.1093/biosci/bix014

Lehner, B., Grill, G. (2013) Global river hydrography and network routing: baseline data and new approaches to study the world's large river systems. Hydrological Processes 27, 2171-2186. doi:10.1002/hyp.9740

Examples

sim <- simulate_enm_data(seed = 1, n_presence = 150)
m <- delimit_m(sim$presence, link_km = 120, thin_km = 5)
m
#> Accessible area (M): method delaunay
#> Linking distance L = 120 km (set by hand); L2 = 120 km; 1 cluster(s) at L
#> Records: 150 read, 0 outside the extent or excluded, 150 after thinning to 5 km
#> Closing 60 km; holes filled: TRUE; corridors: FALSE
#> 
#>             part area_km2 records_inside_pct
#>        automatic   390427                100
#>  added_by_expert        0                 NA
#>                M   390427                100
plot_m_area(m)

# an expert polygon added to the automatic M
extra <- sf::st_sfc(sf::st_polygon(list(rbind(c(22, 50), c(24, 50),
  c(24, 51), c(22, 51), c(22, 50)))), crs = 4326)
m2 <- delimit_m(sim$presence, link_km = 120, thin_km = 5, add = extra)
m_report(m2)
#>              part area_km2 records_inside_pct
#> 1       automatic   390427                100
#> 2 added_by_expert      844                 NA
#> 3               M   391271                100