ellipsoid_projection {tenm} | R Documentation |
ellipsoid_projection: function to project an ellipsoid model
Description
Function to project an ellipsoid model using the shape matrix (covariance matrix) of the niche variables.
Usage
ellipsoid_projection(
envlayers,
centroid,
covar,
level = 0.95,
output = "suitability",
plot = TRUE,
size,
xlab1 = "niche var 1",
ylab1 = "niche var 2",
zlab1 = "S",
alpha = 0.1,
...
)
Arguments
envlayers |
A SpatRaster object of the niche variables. |
centroid |
A vector with the values of the centers of the ellipsoid
(see |
covar |
The shape matrix (covariance) of the ellipsoid
(see |
level |
The proportion of points to be included inside the ellipsoid |
output |
The output distance: two possible values "suitability" or "mahalanobis". By default the function uses "suitability". |
plot |
Logical If |
size |
The size of the points of the niche plot. |
xlab1 |
For x label for 2-dimensional histogram |
ylab1 |
For y label for 2-dimensional histogram |
zlab1 |
For z label for 2-dimensional histogram |
alpha |
Control the transparency of the 3-dimensional ellipsoid |
... |
Arguments passed to |
Value
Returns a SpatRaster of suitability values.
Examples
library(tenm)
data("abronia")
tempora_layers_dir <- system.file("extdata/bio",package = "tenm")
abt <- tenm::sp_temporal_data(occs = abronia,
longitude = "decimalLongitude",
latitude = "decimalLatitude",
sp_date_var = "year",
occ_date_format="y",
layers_date_format= "y",
layers_by_date_dir = tempora_layers_dir,
layers_ext="*.tif$")
abtc <- tenm::clean_dup_by_date(abt,threshold = 10/60)
future::plan("multisession",workers=2)
abex <- tenm::ex_by_date(this_species = abtc,train_prop=0.7)
abbg <- tenm::bg_by_date(this_species = abex,
buffer_ngbs=10,n_bg=50000)
future::plan("sequential")
mod <- tenm::cov_center(data = abex$env_data,
mve = TRUE,
level = 0.975,
vars = c("bio_05","bio_06","bio_12"))
layers_path <- list.files(file.path(tempora_layers_dir,
"2016"),
pattern = ".tif$",full.names = TRUE)
elayers <- terra::rast(layers_path)
nmod <- ellipsoid_projection(envlayers = elayers[[names(mod$centroid)]],
centroid = mod$centroid,
covar = mod$covariance,
level = 0.99999,
output = "suitability",
size = 3,
plot = TRUE)