Skip to contents

This function provides a flexible framework for calculating various biodiversity indicators on a spatial grid or as a time series. It prepares the data, creates a grid, calculates indicators, and formats the output into an appropriate S3 object ('indicator_map' or 'indicator_ts').

Usage

compute_indicator_workflow(
  data,
  type,
  dim_type = c("map", "ts"),
  ci_type = c("norm", "basic", "perc", "bca", "none"),
  cell_size = NULL,
  level = c("cube", "continent", "country", "world", "sovereignty", "geounit"),
  region = "Europe",
  ne_type = c("countries", "map_units", "sovereignty", "tiny_countries"),
  ne_scale = c("medium", "small", "large"),
  output_crs = NULL,
  first_year = NULL,
  last_year = NULL,
  spherical_geometry = TRUE,
  make_valid = FALSE,
  num_bootstrap = 1000,
  ...
)

Arguments

data

A data cube object (class 'processed_cube').

type

The indicator to calculate. Supported options include:

  • 'obs_richness': Observed species richness.

  • 'total_occ': Total number of occurrences.

  • 'newness': Mean year of occurrence.

  • 'occ_density': Density of occurrences.

  • 'williams_evenness', 'pielou_evenness': Evenness measures.

  • 'ab_rarity', 'area_rarity': Abundance-based and area-based rarity scores.

  • 'cum_richness': Cumulative species richness.

  • 'occ_turnover': Occupancy turnover.

  • 'spec_range': Species range size.

  • 'spec_occ': Species occurrences.

  • 'tax_distinct': Taxonomic distinctness.

  • 'hill0': Species richness (estimated by coverage-based rarefaction).

  • 'hill1': Hill-Shannon diversity (estimated by coverage-based rarefaction).

  • 'hill2': Hill-Simpson diversity (estimated by coverage-based rarefaction).

dim_type

Dimension to calculate indicator over (time: 'ts', or space: 'map')

ci_type

Type of bootstrap confidence intervals to calculate. (Default: "norm". Select "none" to avoid calculating bootstrap CIs.)

cell_size

Length of grid cell sides, in km. (Default: 10 for country, 100 for continent or world)

level

Spatial level: 'cube', 'continent', 'country', 'world', 'sovereignty', or 'geounit'. (Default: 'cube')

region

The region of interest (e.g., "Europe"). (Default: "Europe")

ne_type

The type of Natural Earth data to download: 'countries', 'map_units', 'sovereignty', or 'tiny_countries'. (Default: "countries")

ne_scale

The scale of Natural Earth data to download: 'small' - 110m, 'medium' - 50m, or 'large' - 10m. (Default: "medium")

output_crs

The CRS you want for your calculated indicator. (Leave blank to let the function choose a default based on grid reference system)

first_year

Exclude data before this year. (Uses all data in the cube by default.)

last_year

Exclude data after this year. (Uses all data in the cube by default.)

spherical_geometry

If set to FALSE, will temporarily disable spherical geometry while the function runs. Should only be used to solve specific issues. (Default is TRUE)

make_valid

Calls st_make_valid() from the sf package. Increases processing time but may help if you are getting polygon errors. (Default is FALSE).

num_bootstrap

Set the number of bootstraps to calculate for generating confidence intervals. (Default: 1000)

...

Additional arguments passed to specific indicator calculation functions.

Value

An S3 object containing the calculated indicator values and metadata.

Examples

diversity_map <- compute_indicator_workflow(example_cube_1,
                                            type = "obs_richness",
                                            dim_type = "map",
                                            level = "country",
                                            region = "Denmark")
diversity_map
#> Gridded biodiversity indicator map
#> 
#> Name of Indicator: Observed Species Richness 
#> 
#> Map of Denmark 
#> 
#> Projected CRS: EPSG:4326 
#> 
#> Coordinate range:
#>      xmin      ymin      xmax      ymax 
#>  8.121484 54.628857 15.137109 57.736914 
#> 
#> Grid cell size: 0.25 km^2 
#> Number of cells: 168 
#> 
#> Observation years: 1862 - 2023 
#> Total years with observations: 125 
#> 
#> Number of species represented: 106 
#> Number of families represented: 31 
#> 
#> Kingdoms represented: Animalia 
#> 
#> First 10 rows of data (use n = to show more):
#> 
#> # A tibble: 168 × 3
#>    cellid area_km2 diversity_val
#>     <int>   [km^2]         <int>
#>  1     80     447.            21
#>  2     82     447.             7
#>  3     83     447.            30
#>  4     84     447.            40
#>  5     85     447.            43
#>  6    122     445.            20
#>  7    123     445.            29
#>  8    124     445.            17
#>  9    125     445.            32
#> 10    126     445.            40
#> # ℹ 158 more rows