
Place new points in the niche space of a niche_coverage result
Source:R/niche_coverage.R
classify_points.RdClassifies points (e.g. fossil or evaluation sites, sites of a future
projection, or cells of the region under another climate) in the
environmental space and grid fitted by niche_coverage(), and says, for
each, whether its conditions are known from regional records. This is the
decisive test of whether a nested model can help: a regional model
misses conditions that are known only from elsewhere; where its errors
fall into cells already filled by regional records, extending the model
to the whole range will not fix them.
Usage
classify_points(
x,
values = NULL,
points = NULL,
env = NULL,
predicted = NULL,
far = 3,
coords = NULL,
points_crs = "EPSG:4326"
)
# S3 method for class 'niche_coverage'
predict(object, newdata, env = NULL, ...)Arguments
- x
Result of
niche_coverage().- values
A data.frame with one column per variable of
x(the layer names), e.g. values at fossil sites under the climate of their time. Or givepointsandenv.- points, env
Points (data.frame, CSV path,
sf,SpatVector) and layers (same variable names) to extract the values from.- predicted
Optional logical vector: whether the model predicted each point as suitable. Gives a table of misses per category.
- far
Points farther than
fartimes the half range of the whole-range scores from their centre give a units warning.- coords, points_crs
Coordinate columns and CRS of
points.- object
Result of
niche_coverage().- newdata
Values (a data.frame with the variables) or points with
env.- ...
Passed to
classify_points().
Value
A data.frame of class niche_classes: pc1, pc2, cell,
category, regional_records (in the point's cell),
regional_density (percentile of that number among the cells with
regional records) and, if given, predicted. With predicted, the
table of misses is in attr(x, "misses").
Details
Categories of the cell a point falls into:
filled: niche cell with regional records.elsewhere, available: niche cell known only from records outside the region; the conditions occur in the region.elsewhere, absent: niche cell known only from elsewhere; the region lacks these conditions today.region only: cell with regional records but fewer thanmin_recordswhole-range records.available, unoccupied: no records, but conditions of the region.unoccupied: inside the space of the whole-range records, but no records and not conditions of the region.outside: beyond the range of the scores of the whole-range records, i.e. conditions the species is not known from at all.
Units. The new values must be in the units of the layers used in
niche_coverage(). Points whose scores lie far beyond the scores of the
whole-range records (more than far times their range from its centre)
and variables whose median lies far outside the range of the
whole-range records give a warning; a common cause is a variable in
Kelvin in one data set and in degrees Celsius in the other.
Status and limits. A preENM method on the niche space of Goicolea et
al. (2025) as computed by niche_coverage(). The categories depend on
that grid (n_bins) and on min_records: a coarser grid puts more
points into filled cells, so check that the conclusion holds for the
other grids of the robustness table.
References
Goicolea, T., Adde, A., Broennimann, O., Garcia-Vinas, J.I., Mateo-Sanchez, M.C., Aroca-Fernandez, M.J., Guisan, A., Mateo, R.G. (2025) Spatially-nested hierarchical species distribution models to overcome niche truncation in national-scale studies. Ecography 2025, e07328. doi:10.1111/ecog.07328
Examples
sim <- simulate_enm_data(seed = 1, n_presence = 200)
west <- terra::as.polygons(terra::ext(14, 17, 49, 55), crs = "EPSG:4326")
nc <- niche_coverage(sim$presence, sim$env, west, n_boot = 0, n_null = 0)
# the region under a warmer climate
warm <- sim$env + 0.2
names(warm) <- names(sim$env)
cells <- terra::spatSample(terra::crop(warm, west), 200, na.rm = TRUE)
cl <- classify_points(nc, values = cells,
predicted = runif(nrow(cells)) > 0.3)
cl
#> Points in the niche space: 200
#>
#> category points share
#> filled 74 37%
#> elsewhere, available 4 2%
#> elsewhere, absent 54 27%
#> unoccupied 5 2%
#> outside 63 32%
#>
#> Misses (points the model did not predict) per category:
#> category missed predicted share_of_misses miss_rate
#> filled 21 53 34% 28%
#> elsewhere, available 0 4 0% 0%
#> elsewhere, absent 15 39 24% 28%
#> unoccupied 2 3 3% 40%
#> outside 24 39 39% 38%
#>
#> IN SHORT
#> - 34% of the misses lie in cells filled by regional records: the regional
#> model knows these conditions, so a nested model would not help there
#> (look at the model, the variables or the records instead).
#> - 24% lie in cells known only from records outside the region: a nested model
#> could help these.