Skip to contents

The connectivity analysis behind delimit_m(): thins the records, computes their minimum spanning tree (single-linkage clustering) and derives the linking distance L and the second distance L2. Use it, with plot_linking(), to see how the number of separate clusters changes with the linking distance before choosing or accepting L.

Usage

linking_distance(
  points,
  link_km = NULL,
  link_search = c(100, 600),
  link_fallback = c("stop", "upper"),
  link2_max_km = 1000,
  thin_km = 10,
  group = NULL,
  priority = NULL,
  priority_col = "source",
  extent = NULL,
  exclude = NULL,
  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()).

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.

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()).

extent

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

exclude

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

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_linking: a list with L and L2 (km), auto (whether L was derived from the data), n_clusters (at L), table (number of clusters, largest cluster and singletons for a range of linking distances), links (the spanning-tree edges, km) and the thinned points.

Details

The spanning tree is computed from the Delaunay triangulation, which contains it, so memory use grows linearly with the number of records (a full distance matrix would not fit for tens of thousands of records).

Status and what to vary. A preENM method; the concept of the accessible area follows Barve et al. (2011). L should change little with thin_km (denser thinning shortens the links) and with link_search within sensible values; m_scenarios() shows how much M changes with L.

Limits. L is a spatial connectivity threshold derived from the records, not a dispersal distance: it reflects how densely the range was recorded as well as the species, and the largest gap need not be a barrier (see delimit_m()).

References

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

Examples

sim <- simulate_enm_data(seed = 1, n_presence = 150)
lk <- linking_distance(sim$presence, thin_km = 5, link_search = c(20, 200))
lk
#> Linking distance L = 67 km (derived from the records, searched in 20-200 km)
#> Second linking distance L2 = 107 km
#> 150 thinned records form 2 cluster(s) at L
#> Longest spanning-tree links (km): 107 67 66 57 57 56 54 53 52 52 52 52
#> 
#>  link_km n_clusters largest singletons
#>     10.0        141       3        133
#>     15.0        134       4        123
#>     20.0        115       8         95
#>     30.0         77      12         44
#>     50.0         15      50          5
#>     67.5          2     149          1
#>     75.0          2     149          1
#>    100.0          2     149          1
#>    150.0          1     150          0
#>    200.0          1     150          0
#>    250.0          1     150          0
#>    300.0          1     150          0
#>    400.0          1     150          0
#>    500.0          1     150          0
#>    600.0          1     150          0
#>    800.0          1     150          0
#>   1000.0          1     150          0
#>   1500.0          1     150          0
plot_linking(lk)