| name | biodiversity-data-guide |
| description | Biodiversity data access, species occurrence, and ecological tools |
| metadata | {"openclaw":{"emoji":"🍃","category":"domains","subcategory":"ecology","keywords":["biodiversity","taxonomy","ecology","evolutionary biology"],"source":"wentor-research-plugins"}} |
Biodiversity Data Guide
Access, analyze, and visualize biodiversity data from global databases including GBIF, iNaturalist, and GenBank for ecological and evolutionary research.
Major Biodiversity Data Sources
| Database | Content | Records | API | Cost |
|---|
| GBIF | Species occurrence records | 2.4B+ | Yes | Free |
| iNaturalist | Citizen science observations | 180M+ | Yes | Free |
| GenBank (NCBI) | Genetic sequences | 250M+ | Yes | Free |
| BOLD Systems | DNA barcode records | 15M+ | Yes | Free |
| eBird | Bird observations | 1.3B+ | Yes | Free |
| IUCN Red List | Conservation status | 160,000+ | Yes | Free (with key) |
| OBIS | Marine biodiversity | 100M+ | Yes | Free |
| Catalogue of Life | Taxonomic backbone | 2M+ species | Yes | Free |
| TRY Plant Trait | Plant functional traits | 12M+ | Request | Free |
| WorldClim | Climate data (rasters) | Global | Download | Free |
Querying GBIF (Species Occurrences)
Python (pygbif)
from pygbif import species as sp
from pygbif import occurrences as occ
name_result = sp.name_backbone(name="Panthera tigris", rank="species")
taxon_key = name_result["usageKey"]
print(f"GBIF taxon key: {taxon_key}")
print(f"Status: {name_result['status']}")
print(f"Kingdom: {name_result['kingdom']}")
results = occ.search(
taxonKey=taxon_key,
hasCoordinate=True,
country="IN",
limit=100,
year="2020,2024",
basisOfRecord="HUMAN_OBSERVATION"
)
print(f"Total records matching: {results['count']}")
for record in results["results"][:5]:
print(f" [{record.get('year')}] {record.get('decimalLatitude'):.4f}, "
f"{record.get('decimalLongitude'):.4f} - {record.get(, )}")
R (rgbif)
library(rgbif)
library(sf)
library(ggplot2)
tiger_key <- name_backbone(name = "Panthera tigris")$usageKey
occurrences <- occ_search(
taxonKey = tiger_key,
hasCoordinate = TRUE,
limit = 500,
year = "2020,2024",
basisOfRecord = "HUMAN_OBSERVATION"
)
occ_df <- occurrences$data
coords <- occ_df[, c("decimalLongitude", "decimalLatitude")]
occ_sf <- st_as_sf(coords, coords = c("decimalLongitude", "decimalLatitude"),
crs =
world rnaturalearthne_countriesscale returnclass
ggplot
geom_sfdata world fill
geom_sfdata occ_sf color size alpha
coord_sfxlim ylim
labstitle
theme_minimal
ggsave width height
Species Distribution Modeling
MaxEnt Workflow
library(dismo)
library(raster)
occ_data <- occ_search(taxonKey = tiger_key, hasCoordinate = TRUE,
limit = 1000)$data
occ_points <- occ_data[, c("decimalLongitude", "decimalLatitude")]
occ_points <- na.omit(occ_points)
bioclim <- getData("worldclim", var = "bio", res = 10)
env_values <- extract(bioclim, occ_points)
bg_points randomPointsbioclim n
me_model maxentbioclim occ_points a bg_points
args
prediction predictme_model bioclim
plotprediction main
pointsocc_points pch cex
eval_result evaluateme_model p occ_points a bg_points
x bioclim
printpaste eval_resultauc
Phylogenetic Analysis
Building a Phylogeny
library(ape)
library(phytools)
alignment <- read.FASTA("aligned_sequences.fasta")
dist_matrix <- dist.dna(alignment, model = "TN93")
nj_tree <- nj(dist_matrix)
rooted_tree <- root(nj_tree, outgroup = "outgroup_species")
plot(rooted_tree, type = "phylogram", cex = 0.8)
axisPhylo()
library(phangorn)
data_phyDat <- phyDat(alignment, type = "DNA")
ml_tree <- pml_bb(data_phyDat, model = "GTR+G+I",
rearrangement
Comparative Methods
library(caper)
trait_data <- data.frame(
species = c("Sp_A", "Sp_B", "Sp_C", "Sp_D"),
body_mass = c(5.2, 12.1, 3.8, 45.0),
home_range = c(10, 25, 8, 120)
)
comp_data <- comparative.data(
phy = rooted_tree,
data = trait_data,
names.col = species,
vcv = TRUE
)
pgls_model pglshome_range body_mass
data comp_data
lambda
summarypgls_model
Ecological Data Analysis
Diversity Metrics
import numpy as np
from scipy.stats import entropy
def calculate_diversity(abundance_vector):
"""Calculate common biodiversity metrics."""
n = np.array(abundance_vector)
N = n.sum()
p = n / N
p = p[p > 0]
return {
"species_richness": len(n[n > 0]),
"shannon_H": entropy(p, base=np.e),
"simpson_D": 1 - np.sum(p**2),
"evenness_J": entropy(p, base=np.e) / np.log(len(p)),
"fisher_alpha": estimate_fisher_alpha(n),
"total_abundance": int(N)
}
def estimate_fisher_alpha(n):
"""Estimate Fisher's alpha diversity parameter."""
from scipy.optimize import brentq
S = len(n[n > 0])
N = n.sum()
def equation(alpha):
return alpha * np.log(1 + N/alpha) - S
try:
return brentq(equation, 0.1, 1000)
except ValueError:
return np.nan
abundances = [, , , , , , , , ]
metrics = calculate_diversity(abundances)
key, val metrics.items():
( (val, ) )
Community Analysis
library(vegan)
community <- matrix(c(
10, 5, 3, 0, 1,
8, 12, 0, 2, 3,
0, 1, 15, 8, 0,
2, 0, 12, 10, 1
), nrow = 4, byrow = TRUE,
dimnames = list(paste0("Site", paste0
diversitycommunity index
diversitycommunity index
bc_dist vegdistcommunity method
nmds metaMDScommunity distance k
plotnmds type
env_data data.framehabitat
adonis2community habitat data env_data method
Data Standards and Best Practices
Darwin Core Standard
Darwin Core (DwC) is the standard schema for biodiversity data exchange:
| Term | Description | Example |
|---|
scientificName | Full taxonomic name | "Panthera tigris (Linnaeus, 1758)" |
decimalLatitude | Latitude in decimal degrees | 27.1751 |
decimalLongitude | Longitude in decimal degrees | 78.0421 |
eventDate | Date of observation | "2024-03-15" |
basisOfRecord | Type of record | "HUMAN_OBSERVATION" |
coordinateUncertaintyInMeters | Spatial precision | 100 |
institutionCode | Data provider | "iNaturalist" |
Data Quality Checks
- Coordinate validation: Flag points in oceans for terrestrial species (and vice versa)
- Taxonomic verification: Match names against Catalogue of Life or GBIF backbone
- Temporal consistency: Remove records with impossible dates
- Duplicate detection: Remove spatial and temporal duplicates
- Environmental outliers: Flag occurrences in climatically unsuitable areas
- Sampling bias correction: Use spatial thinning or bias files in SDMs