Chapter 2 Download Occurrence Data
Purpose:
- Download and preview species occurrence records using iDigBio and gatoRs.
Created by ML Gaynor.
2.2 A) Download from iDigBio
Here we use ridigbio to download data.
We show how you can search the iDigBio API for occurrence record by taxonomic designations.
# Search for specific species (Galax urceolata)
iDigBio_GU <- idig_search_records(rq = list(scientificname = "Galax urceolata"))
# Search for all Diapensiaceae occurrences (limit to 1000 for example)
iDigBio_GU_family <- idig_search_records(rq = list(family = "Diapensiaceae"), limit = 1000)
###
### Search the API with a geographic bounding box (e.g. Eastern USA extent)
###
# Search with a geographic bounding box (e.g., eastern USA extent)
rq_input <- list(
scientificname = list(type = "exists"),
family = "Diapensiaceae",
geopoint = list(
type = "geo_bounding_box",
top_left = list(lon = -98.16, lat = 48.92),
bottom_right = list(lon = -64.02, lat = 23.06)
)
)
iDigBio_GU_family_USA <- idig_search_records(rq_input, limit = 1000)
# Save iDigBio results as CSV
write.csv(iDigBio_GU, "data/01_download/iDigBio_GU_2026_07_22.csv", row.names = FALSE)
write.csv(iDigBio_GU_family, "data/01_download/iDigBio_GU_family_2026_07_22.csv", row.names = FALSE)2.3 B) Download Using gatoRs
# Define synonym lists for each focal species
Shortia_galacifolia <- c("Shortia galacifolia", "Sherwoodia galacifolia")
Galax_urceolata <- c("Galax urceolata", "Galax aphylla")
Pyxidanthera_barbulata <- c("Pyxidanthera barbulata", "Pyxidanthera barbulata var. barbulata")
Pyxidanthera_brevifolia <- c("Pyxidanthera brevifolia", "Pyxidanthera barbulata var. brevifolia")
# Use gatoRs to download records with resolved synonyms
gators_download(synonyms.list = Shortia_galacifolia,
write.file = TRUE,
filename = "data/01_download/raw/Shortia_galacifolia_raw_2026_07_22.csv")
gators_download(synonyms.list = Galax_urceolata,
write.file = TRUE,
filename = "data/01_download/raw/Galax_urceolata_raw_2026_07_22.csv")
gators_download(synonyms.list = Pyxidanthera_barbulata,
write.file = TRUE,
filename = "data/01_download/raw/Pyxidanthera_barbulata_raw_2026_07_22.csv")
gators_download(synonyms.list = Pyxidanthera_brevifolia,
write.file = TRUE,
filename = "data/01_download/raw/Pyxidanthera_brevifolia_raw_2026_07_22.csv")2.4 C) Preview Downloaded Files
# Read one downloaded file
rawdf <- read.csv("data/01_download/raw/Shortia_galacifolia_raw_2026_07_22.csv")
# Preview columns and dimensions
names(rawdf)
nrow(rawdf)
# Visualize records interactively - The error message here indicates many points do not have long/lat values
leaflet(rawdf) %>%
addTiles() %>%
addMarkers(label = paste0(rawdf$longitude, ", ", rawdf$latitude))