Calculate Biodiversity Indicators Over Space or Time
Source:R/workflow_functions.R
compute_indicator_workflow.Rd
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').
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.
'density': Density of occurrences.
'williams_evenness', 'pielou_evenness': Evenness measures.
'ab_rarity', 'area_rarity': Abundance-based and area-based rarity scores.
- dim_type
Dimension to calculate indicator over (time: 'ts', or space: 'map')
- cell_size
Length of grid cell sides, in km. (Default: 10 for country, 100 for continent or world)
- level
Spatial level: 'continent', 'country', or 'world'. (Default: 'continent')
- region
The region of interest (e.g., "Europe"). (Default: "Europe")
- 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).
- ...
Additional arguments passed to specific indicator calculation functions.
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 72 446. 32
#> 2 73 446. 34
#> 3 74 446. 47
#> 4 75 446. 48
#> 5 76 446. 37
#> 6 77 446. 21
#> 7 78 446. 33
#> 8 79 446. 32
#> 9 80 446. 29
#> 10 81 446. 41
#> # ℹ 158 more rows