get_geo_richness: calculate the richness of a list of species over a given...

Description Usage Arguments Value See Also Examples

View source: R/internal_functions.R

Description

calculate the richness of a list of species over a given landscape

Usage

1
get_geo_richness(species_list, landscape)

Arguments

species_list

a list of species to include in the richness calculations

landscape

the landscape to calculate the richnness over

Value

a vector with the richness for every cell in the input landscape

See Also

plot_richness

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# get path containing example rasters
datapath <- system.file(file.path("extdata", "WorldCenter"), package="gen3sis")
# get species at t0
species_t_0 <- readRDS(file.path(datapath, 
                        "output/config_worldcenter/species/species_t_0.rds"))
# get landscape at t0
landscape_t_0 <- readRDS(file.path(datapath, 
                          "output/config_worldcenter/landscapes/landscape_t_0.rds"))
# get geo richness
richness_t_0 <- get_geo_richness(species_t_0, landscape_t_0)

# histogram of richness at t0
hist(richness_t_0)

## plot richness using raster and gen3sis color_richness (see plot_richness for alternative)
# combine richness and geographical coordinates
geo_richness_t_0 <- cbind(landscape_t_0$coordinates, richness_t_0)
library(raster)
plot(rasterFromXYZ(geo_richness_t_0), col=color_richness(20))

ZHG2017/Rcpp-packageGen3sis documentation built on Dec. 18, 2021, 8:24 p.m.