Skip to main content

This project automatically downloads taxon-specific images from the GBIF API (https://techdocs.gbif.org/en/openapi/), processes them, and stores both images and metadata in a taxonomically organized structure in a MinIO (https://www.min.io/) bucket.

Project description

๐ŸŒณ GBIF Image Downloader

This project automatically downloads taxon-specific images from the GBIF API, processes them, and stores both images and metadata in a taxonomically organized structure in a MinIO bucket.


Features

  • Loads Latin taxon names from .csv or .xlsx files
  • Resolves taxonKeys automatically via the GBIF API
  • Downloads associated media (images) from GBIF
  • Stores metadata and images in a taxonomic folder structure in MinIO
  • Optionally processes only new GBIF occurrences (crawl_new_entries)
  • Multithreading for parallel processing and uploads
  • Saves Logfiles to persistent volume

Project Structure

โ”œโ”€โ”€ config/
โ”‚   โ””โ”€โ”€ config.yaml                    # Central configuration (bucket, paths, etc.)
โ”œโ”€โ”€ data/
โ”‚   โ”œโ”€โ”€ species_key.csv                # Output: species list with GBIF speciesKeys
โ”‚   โ””โ”€โ”€ tree_list.xlsx                 # Input: original species list
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ anhaltai/
โ”‚       โ”œโ”€โ”€ gbif_downloader/
โ”‚       โ”‚   โ”œโ”€โ”€ crawler/
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py        # Package initialization
โ”‚       โ”‚   โ”‚   โ””โ”€โ”€ base_crawler.py    # Base logic for crawling occurrences
โ”‚       โ”‚   โ”œโ”€โ”€ __init__.py            # Package initialization
โ”‚       โ”‚   โ”œโ”€โ”€ config.py              # Loads global configuration
โ”‚       โ”‚   โ”œโ”€โ”€ config_loader.py       # Loads configuration from YAML
โ”‚       โ”‚   โ”œโ”€โ”€ downloader.py          # Download & upload of occurrences and media
โ”‚       โ”‚   โ”œโ”€โ”€ local_log_handler.py   # Log handler that writes logs to MinIO
โ”‚       โ”‚   โ”œโ”€โ”€ main.py                # Entry point, orchestrates all steps
โ”‚       โ”‚   โ”œโ”€โ”€ tree_list_processor.py # Processes taxon lists, resolves taxonKeys
โ”‚       โ”‚   โ””โ”€โ”€ utils.py               # Utility functions (hashing, upload, etc.)
โ”‚       โ””โ”€โ”€  __init__.py               # Package initialization
โ”‚
โ”œโ”€โ”€ .dockerignore                      # Files to ignore in Docker build
โ”œโ”€โ”€ .env                               # MinIO credentials (not in repo)
โ”œโ”€โ”€ .env-example                       # Example MinIO credentials format
โ”œโ”€โ”€ .gitattributes                     # Git attributes for large file systems
โ”œโ”€โ”€ .gitignore                         # Files to ignore in git
โ”œโ”€โ”€ .gitlab-ci.yml                     # GitLab CI/CD configuration
โ”œโ”€โ”€ Dockerfile                         # Container build
โ”œโ”€โ”€ LICENSE                            # License information
โ”œโ”€โ”€ pyproject.toml                     # Python project configuration
โ”œโ”€โ”€ README.md                          # Project documentation
โ”œโ”€โ”€ requirements.txt                   # Python dependencies
โ””โ”€โ”€ sonar-project.properties           # SonarQube configuration

Usage

Installation

Install dependencies via:

pip install -r requirements.txt

1. Prepare your input file

Create a .csv or .xlsx file with at least the following column:

latin_name
Quercus robur
Fagus sylvatica

2. Adjust your configuration

Edit the file config/config.yaml to set your MinIO connection, output paths, and processing options.
A typical configuration looks like this:

minio:
  bucket: meinewaldki-gbif         # Name of your MinIO bucket
  endpoint: 10.144.46.54:9000           # MinIO/S3 endpoint URL
  secure: false                     # Use HTTPS (true/false)

paths:
  output: gbif/                    # Output directory for images and metadata
  tree_list_input_path: data/tree_list.xlsx      # Path to your input taxon list
  processed_tree_list_path: data/species_key.csv # Path for the processed taxonKey list
  log_dir: logs/                   # Directory for log files

query_params:
  mediaType: StillImage            # Only download images
  limit: 100                       # Number of records per API call
  offset: 0                        # Start offset

options:
  already_preprocessed: True         # Set False to process the taxon list again
  crawl_new_entries: False           # Only process new occurrences if True
  max_threads: 300                   # Number of parallel threads for downloads/uploads
  max_pool_size: 50                  # Max connections in Minio-pool

Query Parameters for GBIF API URL

The parameters used to build the GBIF API request URL are defined in the query_params section of your config/config.yaml. These parameters control which records are fetched from the GBIF API.

Supported parameters:

  • mediaType (e.g. StillImage): Only download records with images.
  • taxonKey: The taxon key.
  • datasetKey: Filter by dataset.
  • country: Filter by country code (e.g. DE for Germany).
  • hasCoordinate: Only records with coordinates (true or false).
  • year, month: Filter by year or month of occurrence.
  • basisOfRecord: Type of record (e.g. HUMAN_OBSERVATION).
  • recordedBy: Filter by collector/observer.
  • institutionCode, collectionCode: Filter by institution or collection.
  • limit: Number of records per API call (pagination, max. 300).
  • offset: Start offset for pagination.

How it works:

  • All parameters in query_params are automatically validated at startup.
  • Only the above parameters are allowed. Invalid parameters will cause the program to stop with an error.

3. Process taxonKey list and resolve taxonKeys

from anhaltai.gbif_downloader.tree_list_processor import TreeListProcessor

processor = TreeListProcessor(input_path="data/tree_list.xlsx",
                              sheet_name="Gehรถlzarten", taxon="speciesKey")
processor.process_tree_list(output_path="data/species_key.csv")

4. Download media and metadata from GBIF

Run the main program:

PYTHONPATH=src python3 src/anhaltai/gbif_extractor/main.py

Note:

  • MinIO credentials must be set in .env see .env-example for the required format.
  • Log files are automatically saved in persistent Volume mnt/logs/.
  • Parallel processing and uploads are controlled by a configurable thread limit.
  • The program will skip old entries if crawl_new_entries is set to True.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

anhaltai_gbif_downloader-0.1.0a204.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

anhaltai_gbif_downloader-0.1.0a204-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

Details for the file anhaltai_gbif_downloader-0.1.0a204.tar.gz.

File metadata

File hashes

Hashes for anhaltai_gbif_downloader-0.1.0a204.tar.gz
Algorithm Hash digest
SHA256 1992d4ec6135c192edb2e1b9e49a4d48b7b0cf8943b6b0cdd6be23a71465024a
MD5 016ccc360a551f1696c9053b92f6f3c4
BLAKE2b-256 38e1e7564a97e46097237e4713d94d6f4108376e2d9471cc8ec851d8d2b25707

See more details on using hashes here.

File details

Details for the file anhaltai_gbif_downloader-0.1.0a204-py3-none-any.whl.

File metadata

File hashes

Hashes for anhaltai_gbif_downloader-0.1.0a204-py3-none-any.whl
Algorithm Hash digest
SHA256 ae86d34da72f2ac15f859833a12aaca85f9efdc1f7ec948ae8a4ef2eaa0914ae
MD5 616d672a4e37ee62f9aa4cf94cd8190f
BLAKE2b-256 3173516149275e09af2aba5d53e963fff46721c06f862313b892c95df02ffbe6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page