if (FALSE) {
library(sp)
library(raster)
data("speciaLists") # list of specialists
data("cyathea.br") # occurrence dataset
# classify
occ.cl <- classify_occ(cyathea.br, speciaLists)
# delimit the geographic space
# land area
data("BR")
# Transform occurrence data in SpatialPointsDataFrame
spdf.occ.cl <- sp::SpatialPoints(occ.cl[, c("decimalLongitude", "decimalLatitude")])
# load climate data
data("r.temp.prec") # mean temperature and annual precipitation
df.temp.prec <- raster::as.data.frame(r.temp.prec)
### Define the environmental space for analysis
# this function will create a boundary of available environmental space,
# analogous to the continent boundary in the geographical space
env.space <- define_env_space(df.temp.prec, buffer.size = 0.05)
# filter by year to be consistent with the environmental data
occ.class.1970 <- occ.cl %>%
dplyr::filter(year >= 1970)
### run the evaluation
cl.eval <- clean_eval(occ.class.1970,
env.space = env.space,
geo.space = BR,
r = r.temp.prec)
#area results
head(cl.eval$area)
### richness maps
## it makes sense if there are more than one species
rich.before.clean <- raster::rasterFromXYZ(cbind(cl.eval$site.coords,
cl.eval$rich$rich.BC))
rich.after.clean <- raster::rasterFromXYZ(cbind(cl.eval$site.coords,
cl.eval$rich$rich.AC))
raster::plot(rich.before.clean)
raster::plot(rich.after.clean)
### species area map
comp.bc <- as.data.frame(cl.eval$comp$comp.BC)
comp.ac <- as.data.frame(cl.eval$comp$comp.AC)
c.villosa.bc <- raster::rasterFromXYZ(cbind(cl.eval$site.coords,
comp.bc$`Cyathea villosa`))
c.villosa.ac <- raster::rasterFromXYZ(cbind(cl.eval$site.coords,
comp.ac$`Cyathea villosa`))
raster::plot(c.villosa.bc)
raster::plot(c.villosa.ac)
}
Run the code above in your browser using DataLab