Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/lets_presab_grid.R
Convert species' ranges (in shapefile format) into a presence-absence matrix based on a grid in shapefile format.
1 2 3 4 5 6 7 8 9 |
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ## Not run:
# Grid
sp.r <- rasterToPolygons(raster(resol = 5))
slot(sp.r, "data") <- cbind("ID" = 1:length(sp.r),
slot(sp.r, "data"))
# Species polygons
data(Phyllomedusa)
projection(Phyllomedusa) <- projection(sp.r)
# PAM
resu <- lets.presab.grid(Phyllomedusa, sp.r, "ID")
# Plot
rich_plus1 <- rowSums(resu$PAM) + 1
colfunc <- colorRampPalette(c("#fff5f0", "#fb6a4a", "#67000d"))
colors <- c("white", colfunc(max(rich_plus1)))
plot(resu$grid, border = "gray40",
col = colors[rich_plus1])
map(add = TRUE)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.