Requires an aoi. i.e. aoi is not optional for this implementation of get_obis
Optional simple feature (sf). Used to limit the occurrences
returned via obis::occurence()
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
Logical. If FALSE, will attempt to load from existing
save_dir
.
Character. data_name
value in envImport::data_map
(or other data_map
)
Dataframe or NULL. Mapping of fields to retrieve. See example
envImport::data_map
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.
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()
Dataframe of occurrences and file saved to save_dir
.
aoi <- sf::st_read(file.path(system.file(package = "envImport"), "aoi.shp"))
#> Reading layer `aoi' from data source
#> `C:\temp\joel\RtmpKSVQ8v\temp_libpath23d833687f18\envImport\aoi.shp'
#> using driver `ESRI Shapefile'
#> Simple feature collection with 1 feature and 1 field
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: 138.3357 ymin: -35.41119 xmax: 138.5762 ymax: -35.19546
#> Geodetic CRS: WGS 84
obis_data <- get_obis(aoi
, save_dir = tempdir()
, data_map = envImport::data_map
, get_new = TRUE
)
#> save_file will be C:/temp/joel/RtmpknG3J8/obis/obis.parquet
#>
Retrieved 3692 records of approximately 3692 (100%)
#> Warning: basisOfRecord is not a column so will not be filtered of values: LIVING_SPECIMEN, FOSSIL_SPECIMEN and MATERIAL_CITATION
#> Joining with `by = join_by(decimalLongitude, decimalLatitude)`
#> Warning: obis : establishmentMeans are not columns in the dataframe, so won't be renamed.
#> Warning: There was 1 warning in `dplyr::mutate()`.
#> ℹ In argument: `dplyr::across(...)`.
#> Caused by warning:
#> ! 5 failed to parse.
#> Joining with `by = join_by(date)`
#> Joining with `by = join_by(date)`
obis_data |>
dplyr::count()
#> # A tibble: 1 × 1
#> n
#> <int>
#> 1 1681
# Removing certain methods
obis_data <- get_obis(aoi
, save_dir = tempdir()
, data_map = envImport::data_map
, removes = list(basisOfRecord = c("PreservedSpecimen"))
, get_new = TRUE
)
#> save_file will be C:/temp/joel/RtmpknG3J8/obis/obis.parquet
#>
Retrieved 3692 records of approximately 3692 (100%)
#> Warning: basisOfRecord is not a column so will not be filtered of values: PreservedSpecimen
#> Joining with `by = join_by(decimalLongitude, decimalLatitude)`
#> Warning: obis : establishmentMeans are not columns in the dataframe, so won't be renamed.
#> Warning: There was 1 warning in `dplyr::mutate()`.
#> ℹ In argument: `dplyr::across(...)`.
#> Caused by warning:
#> ! 5 failed to parse.
#> Joining with `by = join_by(date)`
#> Joining with `by = join_by(date)`
obis_data |>
dplyr::count()
#> # A tibble: 1 × 1
#> n
#> <int>
#> 1 1681