require(ecokit)
require(dplyr)
require(terra)
require(rworldmap)
require(colorRamps)
require(sf)
require(ggplot2)
require(grid)
require(tidyterra)Example 1: Total Number of Recorded Bird Species (10 km Resolution)
Note: This example is part of the Global Sampling Effort Dataset repository, which provides pre-computed, taxon-stratified rasters of spatial sampling effort derived from GBIF occurrence records. For an overview of all available examples, taxonomic groups, etc., see the main page. If you use these data or code, please cite:
El-Gabbas, A. (2026) A global, taxon-stratified, high-resolution sampling-effort dataset from GBIF for bias-aware ecological modelling. Diversity and Distributions 32, no. 5: e70205. https://doi.org/10.1111/ddi.70205.
Setup: Load required packages and define plot theme
global_map <- sf::st_as_sf(rworldmap::getMap(resolution = "high"))common_theme <- ggplot2::theme_void() +
ggplot2::theme(
plot.margin = grid::unit(c(0, 0, 0, 0), "lines"),
legend.position = "right",
legend.box.spacing = grid::unit(10, "pt"),
legend.margin = ggplot2::margin(),
legend.title = ggplot2::element_text(size = 7),
legend.text = ggplot2::element_text(size = 7))Total number of recorded bird species globally (1980-2025; 10 km resolution)
The following call downloads a raster of the total number of recorded bird species globally (1980–2025) at 10 km resolution. The file is saved to the effort_maps directory.
effort_birds <- ecokit::get_sampling_effort(
group = "aves", descendants = "all", metric = "n_sp",
years = "total", resolution = 10, out_dir = "effort_maps")Inspect the returned tibble
The returned tibble contains metadata columns (group, descendants, years, metric, resolution), the OSF file identifier, and the local path to the downloaded GeoTIFF.
dplyr::glimpse(effort_birds)Rows: 1
Columns: 9
$ group <chr> "aves"
$ descendant <chr> "all"
$ year <chr> "total"
$ metric <chr> "n_sp"
$ resolution <dbl> 10
$ name <chr> "n_sp_Aves_res_10.tif"
$ id <chr> "690bf267390b709378e03bea"
$ local_path <chr> "effort_maps/n_sp_Aves_res_10.tif"
$ meta <list> [[<NULL>, <NULL>, "n_sp_Aves_res_10.tif", "file", "/690bf26…
Visualise the raster
Load and transform the raster
Load the downloaded raster, replace zeros with NA (to avoid -Inf after transformation), and apply a log10 transformation for visualisation:
r_map <- terra::rast(effort_birds$local_path[[1]]) %>%
terra::classify(cbind(0, NA)) %>%
log10()The loaded raster can be visualised using standard terra, ggplot2, or other spatial workflows. The maps below illustrate the global and regional patterns.
Compare this example with Example 2, which shows the total number of bird observations rather than species counts.
Global map (log10 scale)
ggplot2::ggplot() +
ggplot2::geom_sf(data = global_map, color = "black", size = 0.25, fill = "grey95") +
tidyterra::geom_spatraster(data = r_map, maxcell = 2.3e6) +
ggplot2::scale_fill_gradientn(colours = colorRamps::matlab.like2(100), na.value = "transparent") +
ggplot2::geom_sf(data = global_map, color = "grey60", size = 0.125, fill = "transparent") +
ggplot2::labs(fill = "# species\n(log10)") +
ggplot2::coord_sf(expand = FALSE) +
common_themeEurope (log10 scale)
r_map2 <- terra::crop(r_map, terra::ext(-11, 37.5, 35, 71))
ggplot2::ggplot() +
tidyterra::geom_spatraster(data = r_map2, maxcell = 2.3e6) +
ggplot2::scale_fill_gradientn(colours = colorRamps::matlab.like2(100), na.value = "transparent") +
ggplot2::geom_sf(data = global_map, color = "grey30", size = 0.2, fill = "transparent") +
ggplot2::labs(fill = "# species\n(log10)") +
ggplot2::coord_sf(expand = FALSE, xlim = c(-11, 37.5), ylim = c(35, 71)) +
common_themeUSA (log10 scale)
r_map2 <- terra::crop(r_map, terra::ext(-125, -66.5, 24.5, 49.5))
ggplot2::ggplot() +
tidyterra::geom_spatraster(data = r_map2, maxcell = 2.3e6) +
ggplot2::scale_fill_gradientn(colours = colorRamps::matlab.like2(100), na.value = "transparent") +
ggplot2::geom_sf(data = global_map, color = "grey30", size = 0.5, fill = "transparent") +
ggplot2::labs(fill = "# species\n(log10)") +
ggplot2::coord_sf(expand = FALSE, xlim = c(-125, -66.5), ylim = c(24.5, 49.5)) +
common_themeIndia (log10 scale)
r_map2 <- terra::crop(r_map, terra::ext(68.1, 97.4, 6.7, 35.5))
ggplot2::ggplot() +
tidyterra::geom_spatraster(data = r_map2, maxcell = 2.3e6) +
ggplot2::scale_fill_gradientn(colours = colorRamps::matlab.like2(100), na.value = "transparent") +
ggplot2::geom_sf(data = global_map, color = "grey30", size = 0.5, fill = "transparent") +
ggplot2::labs(fill = "# species\n(log10)") +
ggplot2::coord_sf(expand = FALSE, xlim = c(68.1, 97.4), ylim = c(6.7, 35.5)) +
common_theme