RichSamp: Estimate richness and sampling completeness

Description Usage Arguments Value Examples

View source: R/RichSamp.R

Description

This code will estimate richness using non-parametric estimators for sampled cells, defined by using the raster provided in the arguments. Completeness will be estimated based on the proportion of estimated species that are actually recorded.

Usage

1
RichSamp(occ.table, in.raster, field.names)

Arguments

occ.table

data frame with species occurrence and sampling information. Must contain coordinates x, coordinates y, species, a sampling event id (e.g. date) and count field.

in.raster

a raster in the same projection of coordinates provided in the occurrence table and with the desired cell size for analyses.

field.names

a vector of field names in the occurrence table in the following order: coordinates x, coordinates y, event id, species name, count and cell field.

Value

A data frame of observed species richness(Species), number of surveys (n), estimated species richness (chao, jack1, jack2, boot) and completeness of sampling (C_chao, C_jack1, C_jack2, C_boot) for each sampled cell. XY coordinates of each cell and standard errors (suffix .se) are also provided.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
## Not run: 
#To compute cell stats for colombian bats
library(lubridate)
library(raster)
library(rgbif)
library(WhereNext)

#Get occurrence data
gbif.key <- name_backbone(name = "Chiroptera")
gbif.res <- DownloadGBIF(gbif.key$orderKey, "your username", "your email", "your password", "CO") #Enter your GBIF credentials here

#Get environmental data
col <- getData("GADM", country="COL",level=0)
env.vars <- getData("worldclim", var="bio", res=5)
env.vars <- crop(env.vars, col)
env.vars <- mask(env.vars, col)
env.vars <- Normalize(env.vars) #Normalize environmental variables
env.vars <- RemCorrLayers(env.vars, 0.8) #Remove variables correlated more than r=0.8.

#Do minimal occ.table cleaning
occ.table <- gbif.res$occ.table
occ.table$eventDate <- as_date(occ.table$eventDate)
occ.table$individualCount <- 1 #Data is presence only
occ.table.clean <- subset(occ.table, !is.na(eventDate) & taxonRank=="SPECIES")
row.names(occ.table.clean) <- 1:nrow(occ.table.clean)
occ.table.clean <- CoordinateCleaner::clean_coordinates(occ.table.clean,
                                                        lon="decimalLongitude",
                                                        lat="decimalLatitude",
                                                        species="species",
                                                        countries = "countryCode",
                                                        value="clean",
                                                        tests=c("capitals","centroids", "equal", "gbif",
                                                                "institutions", "outliers", "seas","zeros"))

#Estimate cell sampling stats & filter occurrence data
occ.table.clean$cell <- cellFromXY(env.vars, occ.table.clean[, c("decimalLongitude","decimalLatitude")])
cell.stats <- RichSamp(occ.table.clean, env.vars, c("decimalLongitude","decimalLatitude","eventDate","species","individualCount","cell"))
selected.cells <- cell.stats$cell[which(cell.stats$n>3&cell.stats$Species>5)] #Consider places with at least 3 sampling events and 5 species recorded as well sampled
occ.table.sel <- occ.table.clean[which(occ.table.clean$cell %in% selected.cells), ] #Use only ocurrences of well sampled cells

## End(Not run)

jivelasquezt/WhereNext-Pkg documentation built on Oct. 11, 2021, 9:46 p.m.