get_obis: Get data using 'robis::occurrence()'

View source: R/get_obis.R

get_obisR Documentation

Get data using robis::occurrence()

Description

Requires an aoi. i.e. aoi is not optional for this implementation of get_obis

Usage

get_obis(
  aoi = NULL,
  save_dir = NULL,
  get_new = FALSE,
  name = "obis",
  data_map = NULL,
  filter_inconsistent = TRUE,
  removes = list(basisOfRecord = c("LIVING_SPECIMEN", "FOSSIL_SPECIMEN",
    "MATERIAL_CITATION")),
  ...
)

Arguments

aoi

Optional simple feature (sf). Used to limit the occurrences returned via obis::occurence()

save_dir

Character. Path to directory into which to save outputs. If NULL results will be saved to here::here("out", "ds", "obis"). File will be named obis.parquet

get_new

Logical. If FALSE, will attempt to load from existing save_dir.

name

Character. data_name value in envImport::data_map (or other data_map)

data_map

Dataframe or NULL. Mapping of fields to retrieve. See example envImport::data_map

filter_inconsistent

Logical. If TRUE, inconsistencies between the occurrenceStatus column and either organismQuantity or individualCount are removed. e.g. a record with occurrenceStatus == "ABSENT" but individualCount == 1 would be filtered.

removes

Named list. Names need to match column names in the result of a call to robis::occurrence() (i.e. generally Darwin core column names). Levels within each name are matched and, if present, removed. Note that this filtering occurs after download so it does not save on download time and can also be done after a call to get_obis(). It does enable filtering on columns that are not passed through to the return value as they are not in the data_map.

...

Passed to envImport::file_prep()

Value

Dataframe of occurrences and file saved to save_dir.

Examples


aoi <- sf::st_read(file.path(system.file(package = "envImport"), "aoi.shp"))

obis_data <- get_obis(aoi
                      , save_dir = tempdir()
                      , data_map = envImport::data_map
                      , get_new = TRUE
                      )

obis_data |>
  dplyr::count()

# Removing certain methods
obis_data <- get_obis(aoi
                      , save_dir = tempdir()
                      , data_map = envImport::data_map
                      , removes = list(basisOfRecord = c("PreservedSpecimen"))
                      , get_new = TRUE
                      )

obis_data |>
  dplyr::count()

Acanthiza/envImport documentation built on April 14, 2025, 6:17 a.m.