| ps_area | R Documentation |
Calculate the area (or length) of each site in a spatial data set or phylospatial object. The main use
of this function is to derive site weights for phylospatial(); see the site_weight argument of that
function for details.
ps_area(x)
x |
A |
Raster cell areas are calculated with cellSize, which accounts for variation in cell area across latitudes in longitude/latitude rasters. Polygon areas and line lengths are calculated with expanse and perim, respectively. Point sites have no area, so every point is given a value of 1.
A numeric vector with one value per site (including unoccupied sites, for a phylospatial
object), giving area in square kilometers for raster cells and polygons, or length in kilometers
for lines.
phylospatial()
# cells in a longitude/latitude raster shrink toward the poles
r <- terra::rast(nrows = 10, ncols = 10, xmin = -120, xmax = -100, ymin = 30, ymax = 60)
a <- ps_area(r)
range(a)
# one way to use these values as site weights:
comm <- terra::rast(r, nlyrs = 3)
names(comm) <- c("sp1", "sp2", "sp3")
set.seed(1)
comm[] <- rbinom(terra::ncell(comm) * 3, 1, .5)
tree <- ape::rtree(3, tip.label = names(comm))
ps <- phylospatial(comm, tree, site_weight = sqrt(a))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.