## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  eval = FALSE
)

## ----setup--------------------------------------------------------------------
# library(redlist)

## ----step1--------------------------------------------------------------------
# sp <- rl_scientific_name(
#   genus_name = "Corvinella",
#   species_name = "corvina",
#   resolve = TRUE
# )

## ----resolve------------------------------------------------------------------
# rl_name_resolve("Corvinella", "corvina")
# #> currentCanonicalSimple: "Lanius corvinus"   isSynonym: TRUE   matchType: "Exact"

## ----step3--------------------------------------------------------------------
# occ <- rl_occurrences(
#   sp,
#   year = ">2025",
#   basis_of_record = c("HUMAN_OBSERVATION", "MACHINE_OBSERVATION"),
#   limit = 500
# )
# nrow(occ)
# #> [1] 500

## ----step4--------------------------------------------------------------------
# occ_check <- rl_check_occurrences(
#   x = occ,
#   correct = c("duplicates", "outliers", "country", "ocean_points", "centroids"),
#   terrestrial = FALSE
# )
# nrow(occ_check)

## ----precision----------------------------------------------------------------
# occ_precise <- rl_check_occurrences(occ, correct = "coordinate_precision")

## ----inline-check-------------------------------------------------------------
# occ <- rl_occurrences(
#   sp,
#   year = ">2025",
#   correct = c("duplicates", "outliers")
# )

## ----step5--------------------------------------------------------------------
# aoo <- rl_aoo(occ_check)
# aoo
# #> metric area_km2 n_records n_occupied_cells cell_size_km category_b2
# #>    AOO      ...       ...              ...            2         ...
# 
# eoo <- rl_eoo(occ_check)

## ----map----------------------------------------------------------------------
# plot(sf::st_geometry(eoo), border = "steelblue")
# plot(sf::st_geometry(occ_check), pch = 20, cex = 0.5, add = TRUE)

## ----full---------------------------------------------------------------------
# sp <- rl_scientific_name("Corvinella", "corvina", resolve = TRUE)
# 
# occ <- rl_occurrences(
#   sp,
#   year = ">2025",
#   basis_of_record = c("HUMAN_OBSERVATION", "MACHINE_OBSERVATION"),
#   limit = 500
# )
# 
# occ_check <- rl_check_occurrences(
#   occ,
#   correct = c("duplicates", "outliers", "country", "ocean_points", "centroids"),
#   terrestrial = FALSE
# )
# 
# rl_aoo(occ_check)
# rl_eoo(occ_check)

