
Generate collection event keys from taxon name, date, and coordinates
Source:R/get_collections.R
get_collections.RdBuilds a composite key for each occurrence record by combining the
accepted taxon name from check_taxon(), the collection date, and the rounded
geographic coordinates. Records sharing the same key are likely to represent
the same collection event and can be treated as duplicates.
Arguments
- occ_import
An
importobject returned byimport_records().- taxa_checked
A
occ_taxaobject returned bycheck_taxon(), used to supply the accepted taxon name for each record.- precision
Integer number of decimal places used to round latitude and longitude when constructing the spatial portion of the key. This indirectly controls the spatial tolerance for treating two records as the same collection event. Typical choices:
1: ~10 km2: ~1 km (default)3: ~100 m4: ~10 m
The default of
2balances the fact that GBIF coordinates are often recorded to 5 decimal places (~1 m) whereas the accompanyingcoordinateUncertaintyInMetersis commonly around 500 m, making sub-100 m grouping unreliable without additional filtering.
Value
A list of class "collections" with four elements:
occ_key: adata.tableof the occurrence records with an addedcollection_keycolumn.complete_keys: the number of distinct complete keys.incomplete_keys: the number of distinct incomplete keys (those with at least oneNAcomponent).runtime: the elapsed execution time.
Details
Key construction
The collection key is a pipe-delimited string with four components:
wcvp_taxon_name: the accepted taxon name fromtaxa_checked.eventDate_numeric: theeventDatefield with time-of-day and ISO separators removed, parsed as a date withlubridate::parse_date_time()(accepting truncatedymdorders), and converted to a numeric value.rounded_latitudeandrounded_longitude:decimalLatitudeanddecimalLongituderounded toprecisiondecimal places.
Any component that ends up as NA produces an incomplete key.
Choosing precision
GBIF occurrence records often carry coordinates at 5 decimal places (~1 m
at the equator) alongside a coordinateUncertaintyInMeters field that
typically ranges from tens to hundreds of metres. Rounding coordinates via
precision lets you define a spatial tolerance appropriate for your data
quality expectations, effectively deciding how close two records must be to
share a key.
See also
set_vouchers(), which consumes the output of this function.