Prepare data
library(impIndicator)
library(b3gbi) # General biodiversity indicators for data cubeslibrary(dplyr) # Data wranglinglibrary(knitr) # Nice tables
Process GBIF data from the R environment
Import GBIF data using read.csv()
, readr::read_csv()
, or readxl::read_excel()
based on the data set format.
Here is an example a GBIF occurrences data with the minimum required columns.decimalLatitude
, decimalLongitude
, species
, speciesKey
, coordinateUncertaintyInMeters
and year
decimalLatitude | decimalLongitude | species | speciesKey | coordinateUncertaintyInMeters | year |
---|---|---|---|---|---|
-33.47209 | 26.25137 | Acacia mearnsii | 2979775 | 25 | 2024 |
-32.34151 | 19.02159 | Acacia mearnsii | 2979775 | 8 | 2024 |
-34.56317 | 19.79653 | Acacia longifolia | 2978730 | 5 | 2024 |
-34.66322 | 19.80716 | Acacia cyclops | 2980425 | NA | 2024 |
-34.38089 | 19.22371 | Acacia longifolia | 2978730 | 15 | 2024 |
-33.01186 | 18.36404 | Acacia saligna | 2978552 | 4 | 2024 |
-33.68421 | 18.70806 | Acacia saligna | 2978552 | 15 | 2024 |
-34.33013 | 18.99397 | Acacia longifolia | 2978730 | 4 | 2024 |
-26.19055 | 28.11916 | Acacia mearnsii | 2979775 | 9 | 2024 |
-34.42525 | 19.86027 | Acacia cyclops | 2980425 | 15 | 2024 |
The region
of the study has to be given as a shapefile of the study area or a character representing the country of study area. An example is:
southAfrica_sf#> Simple feature collection with 1 feature and 0 fields#> Geometry type: MULTIPOLYGON#> Dimension: XY#> Bounding box: xmin: 16.48333 ymin: -34.822 xmax: 32.89043 ymax: -22.13639#> Geodetic CRS: WGS 84#> geometry#> 1 MULTIPOLYGON (((31.2975 -22...
acacia_cube <- taxa_cube( taxa = taxa_Acacia, region = southAfrica_sf, first_year = 2010, last_year = 2023)
The cube is a sim_cube
object. Below is an example of the acacia taxa in South Africa:
# View processed cubeacacia_cube#>#> Simulated data cube for calculating biodiversity indicators#>#> Date Range: 2010 - 2023#> Number of cells: 385#> Grid reference system: custom#> Coordinate range:#> xmin xmax ymin ymax#> 16.60833 31.35833 -34.69700 -22.94701#>#> Total number of observations: 5663#> Number of species represented: 28#> Number of families represented: Data not present#>#> Kingdoms represented: Data not present#>#> First 10 rows of data (use n = to show more):
Download from GBIF website
The cube can be generated by downloading the GBIF with rgbif::occ_data()
Cube with standard grid
impIndicator works other cubes with standard grid cell, such as, eea and eqdgc which are processed from b3gbi::process_cube()
. An example is the mammal_cube in the b3gbi
package.
# Load GBIF data cubecube_name <- system.file("extdata", "denmark_mammals_cube_eqdgc.csv", package = "b3gbi")
# Prepare cubemammal_cube <- b3gbi::process_cube(cube_name, first_year = 2000)
# View cubemammal_cube#>#> Processed data cube for calculating biodiversity indicators#>#> Date Range: 2000 - 2024#> Single-resolution cube with cell size 0.25degrees#> Number of cells: 265#> Grid reference system: eqdgc#> Coordinate range:#> xmin xmax ymin ymax#> 3.375 15.125 54.375 58.125#>#> Total number of observations: 191676#> Number of species represented: 97#> Number of families represented: 31#>#> Kingdoms represented: Animalia#>#> First 10 rows of data (use n = to show more):