View source: R/lets_presab_grid.R
lets.presab.grid | R Documentation |
Convert species' ranges (in shapefile format) into a presence-absence matrix based on a grid in shapefile format.
lets.presab.grid(
shapes,
grid,
sample.unit,
remove.sp = TRUE,
presence = NULL,
origin = NULL,
seasonal = NULL
)
shapes |
Object of class |
grid |
Object of class shapefile representing the spatial grid (e.g. regular/irregular cells, political divisions, hexagonal grids, etc). The grid and the shapefiles must be in the same projection. |
sample.unit |
Object of class |
remove.sp |
Logical, if |
presence |
A vector with the code numbers for the presence type to be considered in the process (for IUCN spatial data https://www.iucnredlist.org/resources/spatial-data-download, see metadata). |
origin |
A vector with the code numbers for the origin type to be considered in the process (for IUCN spatial data). |
seasonal |
A vector with the code numbers for the seasonal type to be considered in the process (for IUCN spatial data). |
This function is an alternative way to create a presence absence matrix when users already have their own grid.
The result is a list
containing two objects:
(I) A matrix the species presence (1) and absence (0) values per sample unity.
(II) The original grid.
Bruno Vilela & Fabricio Villalobos
plot.PresenceAbsence
lets.presab.birds
lets.shFilter
## Not run:
# Species polygons
data("Phyllomedusa")
data("wrld_simpl")
# Grid
sp.r <- terra::as.polygons(terra::rast(resol = 5,
crs = terra::crs(Phyllomedusa),
xmin = -93, xmax = -29, ymin = -57, ymax = 15))
sp.r$ID <- 1:length(sp.r)
# PAM
resu <- lets.presab.grid(Phyllomedusa, sp.r, "ID")
# Plot
rich_plus1 <- rowSums(resu$PAM[, -1]) + 1
colfunc <- colorRampPalette(c("#fff5f0", "#fb6a4a", "#67000d"))
colors <- c("white", colfunc(max(rich_plus1)))
plot(resu$grid, border = "gray40",
col = colors[rich_plus1])
plot(sf::st_geometry(wrld_simpl), add = TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.