Skip to content

Use facets in the GBIF connector#110

Draft
jacquesfize wants to merge 7 commits intomainfrom
facet-connector-gbif
Draft

Use facets in the GBIF connector#110
jacquesfize wants to merge 7 commits intomainfrom
facet-connector-gbif

Conversation

@jacquesfize
Copy link
Copy Markdown
Collaborator

@jacquesfize jacquesfize commented Dec 9, 2025

Part of PR #32

This PR proposes using the facet feature in the GBIF API, which offers several key advantages:

  • Performance: It is faster and lighter than the standard occurrences/search query.
  • Accuracy: It provides the true count of occurrences in a specified area.

However, the GBIF API only returns GBIF taxon identifiers. To avoid making N separate queries (where N = number of taxa) to fetch missing data for each taxon, we query the Wikidata API. This allows us to retrieve, in a single request, information such as:

  • Vernacular names
  • Scientific names
  • iNaturalist IDs (explained below)

Wikidata was chosen because it can fetch data for multiple taxa at once and includes links to other data sources.


SPARQL Query to Fetch Taxon Information

SELECT ?taxon ?taxonLabel ?gbifID ?iNatID ?scientificName ?rankLabel
WHERE {
  VALUES ?gbifID { "2435099" "5219404" "2437894" "2440020" }

  ?taxon wdt\:P846 ?gbifID .              # GBIF taxon ID
  OPTIONAL { ?taxon wdt\:P3151 ?iNatID . } # iNaturalist taxon ID
  OPTIONAL { ?taxon wdt\:P225 ?scientificName . }  # Scientific name
  OPTIONAL { ?taxon wdt\:P105 ?rank . }    # Taxonomic rank

  SERVICE wikibase\:label { bd\:serviceParam wikibase\:language "en,fr". }
}

Why the iNaturalist ID?

Wikidata does not always provide all taxonomic ranks. To fill in these gaps without making too many queries, we use the iNaturalist API, which allows us to fetch information for up to 30 taxa in a single request.

@jacquesfize
Copy link
Copy Markdown
Collaborator Author

Since a lot of data are fetched from Wikidata, maybe all data (vernacular names, scientific name) should also be fetch from Wikidata ! Some other interesting variables could be added (habitat, weight, etc.)

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 11, 2026

🚀 Déploiement Netlify réussi

URL de prévisualisation: https://facet-connector-gbif--bam-widget.netlify.app

  • Branche: facet-connector-gbif
  • Commit: f30efc17081da703327a926d4b179438a8b093e5
  • Environment: Preview

Cette URL restera stable pour tous les futurs déploiements de cette branche.

Facet, the second to fetch vernacularName, scientificName from
Wikidata and the last one to fetch taxonomic info from iNaturalist API
@jacquesfize jacquesfize mentioned this pull request Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant