lets.presab.grid: Create a presence-absence matrix of species' geographic...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/lets_presab_grid.R

Description

Convert species' ranges (in shapefile format) into a presence-absence matrix based on a grid in shapefile format.

Usage

1
2
3
4
5
6
7
8
9
lets.presab.grid(
  shapes,
  grid,
  sample.unit,
  remove.sp = TRUE,
  presence = NULL,
  origin = NULL,
  seasonal = NULL
)

Arguments

shapes

Object of class SpatialPolygonsDataFrame (see function readShapePoly to open these files) containing the distribution of one or more species. Species names should be in a column (within the .DBF table of the shapefile) called BINOMIAL/binomial or SCINAME/sciname.

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 character with the name of the column (in the grid) representing the sample units of the presence absence matrix.

remove.sp

Logical, if TRUE the final matrix will not contain species that do not match any cell in the grid.

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).

Details

This function is an alternative way to create a presence absence matrix when users already have their own grid.

Value

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.

Author(s)

Bruno Vilela & Fabricio Villalobos

See Also

plot.PresenceAbsence

lets.presab.birds

lets.shFilter

Examples

 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)

letsR documentation built on Oct. 27, 2020, 1:07 a.m.