Skip to contents
library(impIndicator)
library(b3gbi)
#> Error in get(paste0(generic, ".", class), envir = get_method_env()) : 
#>   object 'type_sum.accel' not found
library(sf)
#> Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.4.0; sf_use_s2() is TRUE

Process GBIF data from the R environment

  1. 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. 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,
  res = 0.25,
  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 cube
acacia_cube
#> 
#> Simulated data cube for calculating biodiversity indicators
#> 
#> Date Range: 2010 - 2023 
#> Number of cells: 372 
#> Grid reference system: custom 
#> Coordinate range:
#> [1] 16.60833
#> 
#> Total number of observations: 5491 
#> 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):
#> 
#> # A tibble: 5,491 × 8
#>    scientificName   taxonKey minCoordinateUncerta…¹  year cellCode xcoord ycoord
#>    <chr>               <dbl>                  <dbl> <dbl> <chr>     <dbl>  <dbl>
#>  1 Acacia mearnsii   2979775                      8  2010 1376       30.4  -29.7
#>  2 Acacia saligna    2978552                      1  2010 206        18.4  -33.9
#>  3 Acacia implexa    2979232                      1  2010 206        18.4  -33.9
#>  4 Acacia pycnantha  2978604                      1  2010 206        18.4  -33.9
#>  5 Acacia cyclops    2980425                    122  2010 668        18.4  -32.2
#>  6 Acacia mearnsii   2979775                      1  2010 215        20.6  -33.9
#>  7 Acacia mearnsii   2979775                    110  2010 215        20.6  -33.9
#>  8 Acacia saligna    2978552                      1  2011 206        18.4  -33.9
#>  9 Acacia saligna    2978552                      1  2011 144        19.4  -34.2
#> 10 Acacia melanoxy…  2979000                      1  2011 206        18.4  -33.9
#> # ℹ 5,481 more rows
#> # ℹ abbreviated name: ¹​minCoordinateUncertaintyInMeters
#> # ℹ 1 more variable: obs <dbl>

Download from GBIF website

The cube can be generated by downloading the GBIF with rgbif::occ_data()

Cube with stardard 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 cube
cube_name <- system.file("extdata", "denmark_mammals_cube_eqdgc.csv", package = "b3gbi")

# Prepare cube
mammal_cube <- process_cube(cube_name,first_year = 2000)

# View cube

mammal_cube
#> 
#> Processed data cube for calculating biodiversity indicators
#> 
#> Date Range: 2000 - 2024 
#> Single-resolution cube with cell size 0.25degrees ^2
#> 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):
#> 
#> # A tibble: 28,155 × 15
#>     year cellCode  kingdomKey kingdom  familyKey family  taxonKey scientificName
#>    <dbl> <chr>          <dbl> <chr>        <dbl> <chr>      <dbl> <chr>         
#>  1  2000 E006N56DB          1 Animalia      9680 Odoben…  5218819 Odobenus rosm…
#>  2  2000 E008N54BA          1 Animalia      5310 Phocid…  2434793 Phoca vitulina
#>  3  2000 E008N55AA          1 Animalia      5310 Phocid…  2434793 Phoca vitulina
#>  4  2000 E008N55AB          1 Animalia      5307 Mustel…  2433753 Lutra lutra   
#>  5  2000 E008N55AB          1 Animalia      5510 Muridae  7429082 Mus musculus  
#>  6  2000 E008N55AC          1 Animalia      5307 Mustel…  2433753 Lutra lutra   
#>  7  2000 E008N55AC          1 Animalia      5310 Phocid…  2434793 Phoca vitulina
#>  8  2000 E008N55AC          1 Animalia      5310 Phocid…  2434806 Halichoerus g…
#>  9  2000 E008N55AC          1 Animalia      9701 Canidae  5219243 Vulpes vulpes 
#> 10  2000 E008N55AC          1 Animalia      9379 Lepori…  7952072 Lepus europae…
#> # ℹ 28,145 more rows
#> # ℹ 7 more variables: obs <dbl>, minCoordinateUncertaintyInMeters <dbl>,
#> #   minTemporalUncertainty <dbl>, familyCount <dbl>, xcoord <dbl>,
#> #   ycoord <dbl>, resolution <chr>