Skip to contents

Checks which biomes are intersected by the convex hulls of species distributions. By default, uses a preloaded biome shapefile containing four biomes: Humid Tropics, Dry Tropics, Temperate, and Boreal. Users can optionally supply their own biome shapefile as an sf object.

Usage

check_biomes(convex_hulls, biome_sf = NULL)

Arguments

convex_hulls

A named list of convex hulls for each species. Each element should be a list of sf polygon objects representing the convex hulls of a species' distribution.

biome_sf

Optional sf object representing biome polygons. If not provided, the default biome shapefile (biomes.shp) included in the package will be used. Custom biome data must include a column named "BIOME".

Value

A dataframe with species_name and one column per biome. Values are 1 if the species' convex hull intersects the biome, 0 otherwise.

Details

The function ensures that both the biome data and species convex hulls are in the EPSG:4326 (WGS84) coordinate reference system. If CRS is missing, it is assigned automatically. Polygons are validated with st_make_valid() before intersection checks. Returns a dataframe where each row corresponds to a species, and each biome column contains 1 if an intersection occurs, otherwise 0.

Note

Custom biome data must have a "BIOME" column with biome names.

References

Hansen M, et al. (2010). “Quantification of global gross forest cover loss.” Proceedings of the National Academy of Sciences of the U.S.A.. doi:10.1073/pnas.0912668107 .

Examples

# Example: Checking biome intersections for two Abies species
test_data <- data.frame(species_name = c("Abies_cephalonica", "Abies_firma"))
convex_hulls_abies <- get_range_convex_hulls(test_data)
#> Processing species: Abies_cephalonica
#> Processing species: Abies_firma
abies_biomes <- check_biomes(convex_hulls_abies)
#> Reading layer `biomes' from data source 
#>   `/home/runner/work/_temp/Library/GDRarity/extdata/biomes.shp' 
#>   using driver `ESRI Shapefile'
#> Simple feature collection with 4 features and 2 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -172.724 ymin: -55.50009 xmax: 179.7352 ymax: 70.00011
#> CRS:           NA
print(abies_biomes)
#>   Humid Tropics Dry Tropics Temperate Boreal      species_name
#> 1             0           0         1      0 Abies_cephalonica
#> 2             1           0         1      0       Abies_firma