Crop a PresenceAbsence object based on a shapefile provided by the user.
Arguments
- x
A
PresenceAbsence
object.- shp
Object of class SpatVector (see function
terra::vect
) to crop the PresenceAbsence object.- remove.sp
Logical, if
TRUE
the final matrix will not contain species that do not match any cell in the grid.- remove.cells
Logical, if
FALSE
the final matrix will not contain cells in the grid with a value of zero (i.e. sites with no species present).
Examples
if (FALSE) {
data(PAM)
data("wrld_simpl")
# PAM before crop
plot(PAM, xlab = "Longitude", ylab = "Latitude",
main = "Phyllomedusa species richness")
# Crop PAM to Brazil
data(wrld_simpl) # World map
Brazil <- wrld_simpl[wrld_simpl$NAME == "Brazil", ] # Brazil (polygon)
PAM_crop <- lets.pamcrop(PAM, Brazil, remove.sp = TRUE)
plot(PAM_crop, xlab = "Longitude", ylab = "Latitude",
main = "Phyllomedusa species richness (Brazil crop)")
plot(sf::st_geometry(wrld_simpl), add = TRUE)
}