This package is a client for the OBIS API. It includes functions for data access, as well as a few helper functions for visualizing occurrence data and extracting nested MeasurementOrFact or DNADerivedData records.
First some packages:
The occurrence()
function provides access to raw
occurrence data. For example, to fetch all occurrences by scientific
name:
Alternatively, occurrences can be fetched by AphiaID:
Other parameters include geometry
, which accepts
polygons in WKT format:
occurrence("Abra alba", geometry = "POLYGON ((2.59689 51.16772, 2.62436 51.14059, 2.76066 51.19225, 2.73216 51.20946, 2.59689 51.16772))")
WKT strings can be created by drawing on a map using the
get_geometry()
function.
A convenience function map_leaflet()
is provided to
visualize occurrences on an interactive map:
The checklist()
function returns all taxa observed for a
given set of filters.
Just like the occurrence()
function,
checklist()
accepts WKT geometries:
The package also provides access to MeasurementOrFact records
associated with occurrences. When calling occurrence()
,
MeasurementOrFact records can be included by setting
mof = true
.
MeasurementOrFact records are nested in the occurrence, but the
unnest_extension()
function allows you to extract them to a
flat data frame. Use the fields
parameter to indicate which
occurrence fields need to be preserved in the measurements table.
mof <- unnest_extension(occ, extension = "MeasurementOrFact", fields = c("scientificName", "decimalLongitude", "decimalLatitude"))
mof
Note that the MeasurementOrFact fields can be used as parameters to
the occurrence()
function. For example, to only get
occurrences with associated biomass measurements: