Map species attributes in both environmental and geographic spaces
Source:R/lets_maplizer_env.R
lets.maplizer.env.Rd
Summarize species-level attributes (e.g., traits or conservation data) within each cell of environmental and geographic presence–absence matrices, enabling trait-based mapping across environmental gradients and geographic space.
Arguments
- x
An object produced by
lets.envpam
.- y
A numeric vector containing the species attributes to be summarized (e.g., description year, body size).
- z
A character vector with species names corresponding to the values in
y
. These names must match the species columns in the presence-absence matrices in `x`.- func
A function used to summarize the attribute across species in each cell (e.g.,
mean
,median
,sum
). Must return a single numeric value.- ras
Logical. If
TRUE
, the result includes the attribute maps asSpatRaster
objects.
Value
A list with the following elements:
Matrix_env
: A matrix with summarized attribute values in environmental space.Matrix_geo
: A matrix with summarized attribute values in geographic space.Env_Raster
: ASpatRaster
with the attribute values mapped in environmental space.Geo_Raster
: ASpatRaster
with the attribute values mapped in geographic space.
Details
This function is useful for trait-based macroecological analyses that aim to
understand how species attributes vary across environments or space. It uses
the output of lets.envpam
, applies a summary function to the
trait values of all species present in each cell, and returns raster layers
for visualization.
Examples
if (FALSE) { # \dontrun{
# Load data
data("Phyllomedusa")
data("prec")
data("temp")
data("IUCN")
prec <- unwrap(prec)
temp <- unwrap(temp)
PAM <- lets.presab(Phyllomedusa, remove.cells = FALSE)
envs <- lets.addvar(PAM, c(temp, prec), onlyvar = TRUE)
colnames(envs) <- c("Temperature", "Preciptation")
wrld_simpl <- get(utils::data("wrld_simpl", package = "letsR"))
PAM <- lets.pamcrop(PAM, vect(wrld_simpl))
# Create environmental PAM
res <- lets.envpam(PAM, envs, remove.cells = FALSE)
# Map mean description year
res_map <- lets.maplizer.env(res,
y = IUCN$Description_Year,
z = IUCN$Species)
# Plotting trait maps
lets.plot.envpam(res_map)
} # }