ensemble.red: Area of Occupancy (AOO) and Extent of Occurrence (EOO) via...

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

Description

Function ensemble.red is a wrapper function for estimation of AOO and EOO computed for redlisting of species based on IUCN criteria (https://www.iucnredlist.org/about/regional). Function ensemble.chull.create creates a mask layer based on a convex hull around known presence locations, inspired by mcp argument of the map.sdm function.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
ensemble.red(x)

ensemble.chull.create(x.pres = NULL, p = NULL, buffer.width = 0.2,
    buffer.maxmins = FALSE, lonlat.dist = FALSE,
    poly.only = FALSE,
    RASTER.format = "raster", RASTER.datatype = "INT1U", RASTER.NAflag = 255,
    overwrite = TRUE, ...)

ensemble.chull.apply(x.spec = NULL, mask.layer=NULL, keep.old=T,
    RASTER.format="raster", RASTER.datatype="INT1U", RASTER.NAflag=255,
    overwrite=TRUE, ...)

ensemble.chull.buffer.distances(p = NULL, 
    buffer.maxmins = FALSE, lonlat.dist = FALSE)

ensemble.chull.MSDM(p = NULL, a = NULL, species.name = NULL,
    suit.file = NULL, suit.divide = 1000, MSDM.dir = NULL,
    method = "BMCP", threshold = "spec_sens", 
    buffer = "species_specific")

Arguments

x

RasterLayer object (raster), representing 'count' suitability layers (available from the 'count' and 'consensuscount' subdirectories of the 'ensembles' directory)

x.pres

RasterLayer object (raster), representing 'presence' suitability layers (available from the 'presence' and 'consensuspresence' subdirectories of the 'ensembles' directory)

p

known presence locations, available in 2-column (lon, lat) dataframe; see also prepareData and extract

buffer.width

multiplier to create buffer (via gBuffer) by multiplying the maximum distance among the presence locations (calculated via pointDistance)

buffer.maxmins

Calculate the buffer width based on the two neighbouring locations that are furthest apart (maximum of minimum distances from each location).

lonlat.dist

Estimate the distance in km for longitude latitude data.

poly.only

Only return the polygon with the convex hull, but do not create the mask layer.

RASTER.format

Format of the raster files that will be generated. See writeFormats and writeRaster.

RASTER.datatype

Format of the raster files that will be generated. See dataType and writeRaster.

RASTER.NAflag

Value that is used to store missing data. See writeRaster.

overwrite

Overwrite existing raster files. See writeRaster.

...

Additional arguments for writeRaster.

x.spec

RasterLayer object (raster), representing any suitability layer for the species under investigation)

mask.layer

RasterLayer object (raster), representing the mask based on the convex hull around known presence locations. The function will replace all values in x.spec to zero where corresponding values in the mask.layer are zero.

keep.old

keep a copy of the RasterLayer before the mask is applied.

a

absence of background locations, available in 2-column (lon, lat) dataframe.

species.name

name of the species, ideally without spaces.

suit.file

file with raster data corresponding to suitability values of the focal species.

suit.divide

number by which values in the suitability raster should be divided to result in probabilities (BiodiversityR saves data as 1000 * suitability, hence these values need to be divided by 1000).

MSDM.dir

name of the directory where input and processed raster files will be saved.

method

method for MSDM_Posteriori function from c("OBR", "PRES", "LQ", "MCP", "BMCP").

threshold

threshold for MSDM_Posteriori function from c("kappa", "spec_sens", "no_omission", "prevalence", "equal_sens_spec", "sensitivty").

buffer

buffer for MSDM_Posteriori function.

Details

Function ensemble.red calculates AOO (aoo) and EOO (aoo) statistics calculated for areas with different consensus levels on species presence (1 model predicting presence, 2 models predicting presence, ...). In case that these statistics are within IUCN criteria for Critically Endangered (CR), Endangered (EN) or Vulnerable (VU), then this information is added in columns documenting the types of AOO and EOO.

Function ensemble.chull.create first creates a convex hull around known presence locations. Next, a buffer is created around the convex hull where the width of this buffer is calculated as the maximum distance among presence locations (pointDistance) multiplied by argument buffer.width. Finally, the mask is created by including all polygons of predicted species presence that are partially covered by the convex hull and its buffer.

Value

Function ensemble.red returns an array with AOO and EOO Function ensemble.chull.create creates a mask layer based on a convex hull around known presence locations. Function ensemble.chull.MSDM prepares the input data and script for the MSDM_Posteriori function of the MSDM package.

Author(s)

Roeland Kindt (World Agroforestry Centre)

References

Cardoso P. 2017. red - an R package to facilitate species red list assessments according to the IUCN criteria. Biodiversity Data Journal 5:e20530. doi: 10.3897/BDJ.5.e20530

Mendes, P.; Velazco S.J.E.; Andrade, A.F.A.; De Marco, P. (2020) Dealing with overprediction in species distribution models: how adding distance constraints can improve model accuracy, Ecological Modelling, in press. doi: 10.1016/j.ecolmodel.2020.109180

Kindt R. 2018. Ensemble species distribution modelling with transformed suitability values. Environmental Modelling & Software 100: 136-145. doi: 10.1016/j.envsoft.2017.11.009

See Also

ensemble.batch

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
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
## Not run: 

## Not run: 
# based on examples in the dismo package

# get predictor variables
library(dismo)
predictor.files <- list.files(path=paste(system.file(package="dismo"), '/ex', sep=''),
    pattern='grd', full.names=TRUE)
predictors <- stack(predictor.files)
# subset based on Variance Inflation Factors
predictors <- subset(predictors, subset=c("bio5", "bio6", 
    "bio16", "bio17"))
predictors
predictors@title <- "red"

# presence points
presence_file <- paste(system.file(package="dismo"), '/ex/bradypus.csv', sep='')
pres <- read.table(presence_file, header=TRUE, sep=',')

# fit 5 ensemble models (could take some time!)
# (examples for the red package use 100 models)
ensembles <- ensemble.batch(x=predictors, 
    xn=c(predictors),
    species.presence=pres, 
    thin.km=100,
    k.splits=4, k.test=0, 
    n.ensembles=5, 
    SINK=TRUE, 
    ENSEMBLE.best=10, ENSEMBLE.exponent=c(1, 2, 3), 
    ENSEMBLE.min=0.6,
    MAXENT=0, MAXNET=1, MAXLIKE=1, GBM=1, GBMSTEP=0, RF=1, CF=1,
    GLM=1, GLMSTEP=1, GAM=1, GAMSTEP=1, MGCV=1, MGCVFIX=1, 
    EARTH=1, RPART=1, NNET=1, FDA=1, SVM=1, SVME=1, 
    BIOCLIM.O=1, BIOCLIM=1, DOMAIN=1, MAHAL=0, MAHAL01=1,
    PROBIT=TRUE,
    Yweights="BIOMOD",
    formulae.defaults=TRUE)

# first application of ensemble.red before applying the convex hull mask
# AOO and EOO are determined for each count level
library(red)
count.file <- paste(getwd(), 
    "/ensembles/consensuscount/Bradypus variegatus_red.grd", sep="")
count.raster <- raster(count.file)
ensemble.red(count.raster)

# do not predict presence in polygons completely outside convex hull
# of known presence locations
pres.file <- paste(getwd(), 
    "/ensembles/consensuspresence/Bradypus variegatus_red.grd", sep="")
pres.raster <- raster(pres.file)
pres1 <- pres[, -1]
chull.created <- ensemble.chull.create(x.pres=pres.raster, p=pres1)

mask.raster <- chull.created$mask.layer
mask.poly <- chull.created$convex.hull

pres.chull <- ensemble.chull.apply(pres.raster, mask=mask.raster, keep.old=T)

# load previous for plotting
pres.file.old <- paste(getwd(), 
    "/ensembles/consensuspresence/Bradypus variegatus_red_old.grd", sep="")
pres.raster.old <- raster(pres.file.old)

par.old <- graphics::par(no.readonly=T)
par(mfrow=c(1,2))
plot(pres.raster.old, breaks=c(-1, 0, 1), col=c("grey", "green"),
    main="before convex hull")
points(pres1, col="blue")

# load new
pres.file <- paste(getwd(), 
    "/ensembles/consensuspresence/Bradypus variegatus_red.grd", sep="")
pres.raster <- raster(pres.file)
plot(pres.raster, breaks=c(-1, 0, 1), col=c("grey", "green"),
    main="after convex hull")
plot(mask.poly, add=T, border="blue")

# new application of ensemble.red
dev.new()
plot(count.raster, main="before convex hull")
ensemble.red(count.raster)
# all cells where species is predicted not to be present according to the mask layer
# will be modified to a count of zero
count.chull <- ensemble.chull.apply(count.raster, mask=mask.raster, keep.old=T)
# load new
count.file <- paste(getwd(), 
    "/ensembles/consensuscount/Bradypus variegatus_red.grd", sep="")
count.raster <- raster(count.file)
ensemble.red(count.raster)
dev.new()
plot(count.raster, main="after convex hull")
# par.old <- graphics::par(no.readonly=T)

# create a smaller hull (0.05 * largest distance)
# First write back the original absence-presence file
pres.file.original <- paste(getwd(), 
    "/ensembles/consensuspresence/Bradypus variegatus_red_old.grd", sep="")
pres.file <- paste(getwd(), 
    "/ensembles/consensuspresence/Bradypus variegatus_red.grd", sep="")
pres.raster <- raster(pres.file.original)
# save as the original file
writeRaster(pres.raster, filename=pres.file, overwrite=T)
pres.raster <- raster(pres.file)

chull.created <- ensemble.chull.create(x.pres=pres.raster, p=pres1, 
    buffer.width=0.05, lonlat.dist=TRUE)
mask.raster <- chull.created$mask.layer
mask.poly <- chull.created$convex.hull
pres.chull <- ensemble.chull.apply(pres.raster, mask=mask.raster, keep.old=T)

# load previous for plotting
pres.file.old <- paste(getwd(), 
    "/ensembles/consensuspresence/Bradypus variegatus_red_old.grd", sep="")
pres.raster.old <- raster(pres.file.old)

par(mfrow=c(1,2))
plot(pres.raster.old, breaks=c(-1, 0, 1), col=c("grey", "green"),
    main="before convex hull")
points(pres1, col="blue")

# load new
pres.file <- paste(getwd(), 
    "/ensembles/consensuspresence/Bradypus variegatus_red.grd", sep="")
pres.raster <- raster(pres.file)
plot(pres.raster, breaks=c(-1, 0, 1), col=c("grey", "green"),
    main="after convex hull")
plot(mask.poly, add=T, border="blue")


# create a hull based on the distance to the location with the farthest neighbour
# First write back the original absence-presence file
pres.file.original <- paste(getwd(), 
    "/ensembles/consensuspresence/Bradypus variegatus_red_old.grd", sep="")
pres.file <- paste(getwd(), 
    "/ensembles/consensuspresence/Bradypus variegatus_red.grd", sep="")
pres.raster <- raster(pres.file.original)
# save as the original file
writeRaster(pres.raster, filename=pres.file, overwrite=T)
pres.raster <- raster(pres.file)

chull.created <- ensemble.chull.create(x.pres=pres.raster, p=pres1, 
    buffer.maxmins=TRUE, buffer.width=0.9, lonlat.dist=TRUE)
mask.raster <- chull.created$mask.layer
mask.poly <- chull.created$convex.hull
pres.chull <- ensemble.chull.apply(pres.raster, mask=mask.raster, keep.old=T)

# load previous for plotting
pres.file.old <- paste(getwd(), 
    "/ensembles/consensuspresence/Bradypus variegatus_red_old.grd", sep="")
pres.raster.old <- raster(pres.file.old)

par(mfrow=c(1,2))
plot(pres.raster.old, breaks=c(-1, 0, 1), col=c("grey", "green"),
    main="before convex hull")
points(pres1, col="blue")

# load new
pres.file <- paste(getwd(), 
    "/ensembles/consensuspresence/Bradypus variegatus_red.grd", sep="")
pres.raster <- raster(pres.file)
plot(pres.raster, breaks=c(-1, 0, 1), col=c("grey", "green"),
    main="after convex hull")
plot(mask.poly, add=T, border="blue")

par.old <- graphics::par(no.readonly=T)

# how distances were derived
# maximum distance between observations
ensemble.chull.buffer.distances(pres1, lonlat.dist=TRUE)   
# the closest neigbhour that is farthest away from each observation
# this is the distance calculated by MSDM_posteriori for buffer="species_specific"
ensemble.chull.buffer.distances(pres1, buffer.maxmins=TRUE, lonlat.dist=TRUE) 


## End(Not run)

BiodiversityR documentation built on April 20, 2021, 5:07 p.m.