Learn R Programming

letsR (version 4.0)

lets.pamcrop: Crop a PresenceAbsence object based on an input shapefile

Description

Crop a PresenceAbsence object based on a shapefile provided by the user.

Usage

lets.pamcrop(x, shp, remove.sp = TRUE)

Arguments

x

A PresenceAbsence object.

shp

Object of class SpatialPolygonsDataFrame (see function readShapePoly) 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.

Value

The result is an object of class PresenceAbsence croped.

See Also

plot.PresenceAbsence

lets.presab.birds

Examples

Run this code
# NOT RUN {
data(PAM)
# PAM before crop
plot(PAM, xlab = "Longitude", ylab = "Latitude",
     main = "Phyllomedusa species richness")

# Crop PAM to Brazil
require(maptools)    
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)",
     col = colorRampPalette(c("darkgreen", "yellow", "blue")))
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab