Skip to contents

iucn_species_gpkg() splits IUCN shape files into separate gpkg files for each species, and returns their paths. This allows for parallel processing in downstream analysis, and avoids the need to read large shape files again.

Use iucn_spatial_species() and iucn_spatial_features() for quick skimming of the whole dataset, and determine which species to analyze.

Usage

iucn_spatial_species(iucn_source = NULL)

iucn_species_gpkg(iucn_source = NULL, overwrite = FALSE)

Arguments

iucn_source

Path to the directory containing IUCN shape files. iucn_source_path() is used if NULL is given (default).

overwrite

Whether to overwrite existing cache files.

Value

iucn_spatial_species() returns a data.frame extracted from iucn_spatial_features().

iucn_species_gpkg() returns a data.frame with two columns, "sci_name" and "source", to be used for quantify_vector_kgc().

Examples

if (FALSE) { # \dontrun{
options(habistats.iucn_source = "path/to/your/data")
habistats::iucn_source_path()
} # }
old = options(habistats.cache_dir = "~/.cache/habistats-example")

habistats::cache_dir()
#> ~/.cache/habistats-example

habistats::iucn_spatial_species()
#> # A tibble: 4 × 11
#>   kingdom   phylum class order_ family genus sci_name category marine terrestria
#>   <chr>     <chr>  <chr> <chr>  <chr>  <chr> <chr>    <chr>    <lgl>  <lgl>     
#> 1 METALLICA CHORD… MAMM… CARNI… CANID… Stra… Strato … LC       FALSE  TRUE      
#> 2 METALLICA CHORD… AVES  PASSE… CORVI… Diva  Diva sa… LC       FALSE  TRUE      
#> 3 METALLICA TRACH… MAGN… CUCUR… CUCUR… Kai   Kai kis… LC       FALSE  TRUE      
#> 4 METALLICA CHORD… MAMM… CINGU… CHLAM… Elp   Elp tar… EW       FALSE  TRUE      
#> # ℹ 1 more variable: freshwater <lgl>

habistats::iucn_species_gpkg()
#> # A tibble: 4 × 2
#>   sci_name       source                                                         
#>   <chr>          <fs::path>                                                     
#> 1 Strato arctica …A/MAMMALIA/CARNIVORA/CANIDAE/Strato/Strato_arctica/source.gpkg
#> 2 Diva satanica  …ATA/AVES/PASSERIFORMES/CORVIDAE/Diva/Diva_satanica/source.gpkg
#> 3 Kai kiske      …OLIOPSIDA/CUCURBITALES/CUCURBITACEAE/Kai/Kai_kiske/source.gpkg
#> 4 Elp tarkus     …A/MAMMALIA/CINGULATA/CHLAMYPHORIDAE/Elp/Elp_tarkus/source.gpkg

options(old) # reset for this example, not needed in real use