A simple Python function to help downloading occurrences from GBIF.
The function is blocking while GBIF are preparing the download, so a 15-30 minute execution time is not abnormal.
$ pip install gbif-blocking-occurrence-download
To trigger a download, you'll need:
- A GBIF account (username and password).
- A predicate to describe your query. See the documentation to help writing a predicate.
Example code:
import logging
import sys
from gbif_blocking_occurrences_download import download_occurrences
# Increase the log level to INFO if you want to see progress during the (potentially long) function execution
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
username = 'your_gbif_username'
password = 'your_gbif_password'
# See https://www.gbif.org/developer/occurrence#predicates
predicate = {
"predicate": {
"type": "equals",
"key": "DATASET_KEY",
"value": "b7ee2a4d-8e10-410f-a951-a7f032678ffe"
},
}
download_occurrences(
predicate,
username=username,
password=password,
output_path="download.zip",
)
- We're using Poetry to manage dependencies, publish to PyPI, ...
- Code formatted with Black:
$ black .
- We're using pytest for unit testing
- Update
CHANGELOG.md
- Update version number in
pyproject.toml
- Run
$ poetry build
and$ poetry publish
- Push a tag on GitHub:
$ git tag vX.Y.Z
$ git push origin --tags