Skip to content

A simple Python function to help downloading occurrences from GBIF

License

Notifications You must be signed in to change notification settings

niconoe/gbif-blocking-occurrence-download

Repository files navigation

gbif-blocking-occurrence-download

Run unit tests on push PyPI version

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.

Install

$ pip install gbif-blocking-occurrence-download

Example use

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",
)

Development

  • We're using Poetry to manage dependencies, publish to PyPI, ...
  • Code formatted with Black:
$ black .
  • We're using pytest for unit testing

How to issue a new release

  • 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

About

A simple Python function to help downloading occurrences from GBIF

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages