Package {rbiodatacr}


Type: Package
Title: R Client for the BIODATACR Biodiversity Data Platform of Costa Rica
Version: 0.1.2
Description: Provides functions to query occurrence records, species information, and datasets from BIODATACR https://biodiversidad.go.cr, the national biodiversity information platform of Costa Rica managed by the Technical Office of CONAGEBIO. Built on the Atlas of Living Australia (ALA) API infrastructure.
License: MIT + file LICENSE
Encoding: UTF-8
URL: https://github.com/ManuelSpinola/rbiodatacr, https://manuelspinola.github.io/rbiodatacr/
BugReports: https://github.com/ManuelSpinola/rbiodatacr/issues
Suggests: CoordinateCleaner, ggplot2, knitr, rmarkdown, sf, testthat (≥ 3.0.0)
Config/testthat/edition: 3
Imports: cli, dplyr, httr, jsonlite, purrr
VignetteBuilder: knitr
Depends: R (≥ 4.1.0)
LazyData: true
Language: en-US
Config/roxygen2/version: 8.0.0
NeedsCompilation: no
Packaged: 2026-07-22 14:09:32 UTC; manuel_nuevo
Author: Manuel Spinola ORCID iD [aut, cre]
Maintainer: Manuel Spinola <mspinola10@gmail.com>
Repository: CRAN
Date/Publication: 2026-07-22 15:50:02 UTC

Count occurrence records for a taxon

Description

Count occurrence records for a taxon

Usage

bdcr_count(taxon)

Arguments

taxon

Character. Scientific name (e.g. '"Panthera onca"').

Value

Integer with the total number of available records, or 'NA_integer_' if the service is unavailable.

Examples

## Not run: 
bdcr_count("Panthera onca")

## End(Not run)

Count occurrence records for multiple taxa

Description

Count occurrence records for multiple taxa

Usage

bdcr_count_batch(taxa, wait = 1)

Arguments

taxa

Character vector. Scientific names.

wait

Numeric. Seconds to pause between requests. Default 1.

Value

A 'tibble' with columns 'taxon' and 'n_records'.

Examples

## Not run: 
spp <- c("Tapirus bairdii", "Panthera onca")
bdcr_count_batch(spp)

## End(Not run)

Download occurrence records from BIODATACR

Description

Download occurrence records from BIODATACR

Usage

bdcr_occurrences(taxon, rows = 100, start = 0, page_size = 300, wait = 1)

Arguments

taxon

Character. Scientific name of the taxon.

rows

Integer. Maximum number of records to download. Default 100. Pass ‘Inf' (or the taxon’s true total, e.g. from [bdcr_count()]) to download every available record, paginating as needed. If fewer records are downloaded than actually exist, an informative message reports the true total so the result is never mistaken for the complete dataset.

start

Integer. Starting record for pagination. Default 0.

page_size

Integer. Records requested per HTTP call. Default 300. Kept below 'rows' and used to chunk large downloads into several polite requests instead of one giant one.

wait

Numeric. Seconds to pause between paginated requests (only relevant when more than one page is needed). Default 1.

Value

A 'tibble' with columns: 'scientificName', 'vernacularName', 'decimalLatitude', 'decimalLongitude', 'year', 'month', 'basisOfRecord', 'dataResourceName', 'country', 'family', 'species', 'collector', 'license', 'geospatialKosher', 'taxonomicKosher'. Returns an empty 'tibble' if the service is unavailable or no records are found.

Examples

## Not run: 
bdcr_occurrences("Panthera onca", rows = 50)
bdcr_occurrences("Panthera onca")        # primeros 100 (default)
bdcr_occurrences("Panthera onca", rows = Inf)  # todos los registros

## End(Not run)

Download occurrence records for multiple taxa

Description

Download occurrence records for multiple taxa

Usage

bdcr_occurrences_batch(taxa, rows = 100, page_size = 300, wait = 1)

Arguments

taxa

Character vector. Scientific names.

rows

Integer. Maximum records per taxon. Default 100, matching [bdcr_occurrences()]. Pass 'Inf' to download every available record for each taxon; a message will report the true total for any taxon where the download is capped below it.

page_size

Integer. Records requested per HTTP call within each taxon's pagination. Default 300.

wait

Numeric. Seconds to pause between requests (both between taxa and between pages within a taxon). Default 1.

Value

Named list of tibbles, one per taxon. If the service is unavailable for a given taxon, the corresponding element will be an empty 'tibble'.

Examples

## Not run: 
spp <- c("Tapirus bairdii", "Panthera onca")
bdcr_occurrences_batch(spp, rows = 50)
bdcr_occurrences_batch(spp, rows = Inf)  # descarga todos los registros

## End(Not run)

Quality check for occurrence records

Description

Adds a 'quality_flag' column to an occurrence tibble. Requires that 'geospatialKosher' and 'taxonomicKosher' are logical — a condition guaranteed by 'bdcr_occurrences()'.

Usage

bdcr_quality_check(df, min_year = 1950)

Arguments

df

A 'tibble' of occurrence records (output of 'bdcr_occurrences()').

min_year

Integer. Minimum acceptable year. Default 1950.

Value

The same 'tibble' with an additional 'quality_flag' column. Possible values:

'"ok"'

No issues detected.

'"no_coords"'

Missing coordinates.

'"geospatial_issue"'

'geospatialKosher == FALSE'.

'"taxonomic_issue"'

'taxonomicKosher == FALSE'.

'"old_record"'

Year before 'min_year'.

Examples

## Not run: 
df <- bdcr_occurrences("Panthera onca", rows = 50)
bdcr_quality_check(df)

## End(Not run)

Description

Queries the BIE (Biodiversity Information Explorer) index of BIODATACR to retrieve taxonomic information for a species.

Usage

bdcr_species_search(name, rows = 10)

Arguments

name

Character. Scientific name (may be a synonym or partial name).

rows

Integer. Maximum number of results. Default 10.

Value

A 'tibble' with columns: 'name', 'guid', 'commonName', 'scientificName', 'rank', 'taxonomicStatus', 'nameComplete'. Returns an empty 'tibble' if the service is unavailable or no results are found.

Examples

## Not run: 
bdcr_species_search("Panthera onca")

## End(Not run)

Costa Rica national boundary

Description

An 'sf' object with the national boundary of Costa Rica from GADM.

Usage

cr_outline

Format

An 'sf' object with 1 row and the following columns:

GID_0

Country code (CRI)

COUNTRY

Country name

geometry

MULTIPOLYGON geometry

Source

https://gadm.org/