Flags occurrence records based on known distribution data
from the International Union for Conservation of Nature (IUCN) data. This
function checks if an occurrence point for a given species falls within its
documented distribution, allowing for user-defined buffers around the region.
Records are flagged as TRUE if they fall inside the documented
distribution (plus optional buffer) for the species in the IUCN dataset.
Usage
flag_iucn(
data_dir,
occ,
species = "species",
long = "decimalLongitude",
lat = "decimalLatitude",
origin = "native",
presence = "all",
buffer = 20,
progress_bar = FALSE,
verbose = FALSE
)Arguments
- data_dir
(character) Required directory path where the
IUCNdata is saved.- occ
(data.frame or data.table) a data frame containing the occurrence records to be flagged. Must contain columns for species, longitude, and latitude.
- species
(character) the name of the column in
occthat contains the species scientific names. Default is"species".- long
(character) the name of the column in
occthat contains the longitude values. Default is"decimalLongitude".- lat
(character) the name of the column in
occthat contains the latitude values. Default is"decimalLatitude".- origin
(character) vector specifying which origin categories should be considered as part of the species' range. Options are:
"native","introduced","reintroduced","vagrant","origin uncertain","assisted colonisation", and"all". Default is"native".- presence
(character) vector specifying which presence type should be considered as part of the species' range. Options are:
"extant","probably extant","possibly extant","extinct","possibly extinct","presence uncertain", and"all". Default is"all".- buffer
(numeric) buffer distance (in kilometers) to be applied around the region of distribution. Default is
20km.- progress_bar
(logical) whether to display a progress bar during processing. If
TRUE, the'pbapply'package must be installed. Default isFALSE.- verbose
(logical) if
TRUE, prints messages about the progress and the number of species being checked. Default isFALSE.
Value
A data.frame that is the original occ data frame
augmented with a new column named iucn_flag. This column is
logical (TRUE/FALSE) indicating whether the record falls
within the expected distribution (plus buffer) based on the IUCN
data. As with all other flagging functions in RuHere, TRUE
indicates that the record passed this test and is eligible for retention;
FALSE indicates it failed and is flagged as potentially problematic,
and can be removed using remove_flagged(). Records for species not
found in the IUCN data (or lacking distribution polygons for the
selected filters) will have NA in the iucn_flag column.
Examples
# Load example data
data("occurrences", package = "RuHere")
# Get only occurrences from Araucaria
occ <- occurrences[occurrences$species == "Araucaria angustifolia", ]
# Set folder where distributional datasets were saved
# Here, just a sample provided in the package
# You must run 'iucn_here()' beforehand to download the necessary data files
dataset_dir <- system.file("extdata/datasets", package = "RuHere")
# Flag records using IUCN specialist information
occ_iucn <- flag_iucn(data_dir = dataset_dir, occ = occ)
