An easy downloader for the AirBase air quality data.
Project description
๐ฌ AirBase
An easy downloader for the AirBase air quality data.
AirBase is an air quality database provided by the European Environment Agency (EEA). The data is available for download at the portal, but the interface makes it a bit time consuming to do bulk downloads. Hence, an easy Python-based interface.
Read the full documentation at https://airbase.readthedocs.io.
๐ Installation
To install airbase
, simply run
$ pip install airbase
๐ Getting Started
๐บ Get info about available countries and pollutants:
>>> import airbase
>>> client = airbase.AirbaseClient()
>>> client.all_countries
['GR', 'ES', 'IS', 'CY', 'NL', 'AT', 'LV', 'BE', 'CH', 'EE', 'FR', 'DE', ...
>>> client.all_pollutants
{'k': 412, 'CO': 10, 'NO': 38, 'O3': 7, 'As': 2018, 'Cd': 2014, ...
>>> client.pollutants_per_country
{'AD': [{'pl': 'CO', 'shortpl': 10}, {'pl': 'NO', 'shortpl': 38}, ...
>>> client.search_pollutant("O3")
[{'pl': 'O3', 'shortpl': 7}, {'pl': 'NO3', 'shortpl': 46}, ...
๐ Request download links from the server and save the resulting CSVs into a directory:
>>> r = client.request(country=["NL", "DE"], pl="NO3", year_from=2015)
>>> r.download_to_directory(dir="data", skip_existing=True)
Generating CSV download links...
100%|โโโโโโโโโโ| 2/2 [00:03<00:00, 2.03s/it]
Generated 12 CSV links ready for downloading
Downloading CSVs to data...
100%|โโโโโโโโโโ| 12/12 [00:01<00:00, 8.44it/s]
๐พ Or concatenate them into one big file:
>>> r = client.request(country="FR", pl=["O3", "PM10"], year_to=2014)
>>> r.download_to_file("data/raw.csv")
Generating CSV download links...
100%|โโโโโโโโโโ| 2/2 [00:12<00:00, 7.40s/it]
Generated 2,029 CSV links ready for downloading
Writing data to data/raw.csv...
100%|โโโโโโโโโโ| 2029/2029 [31:23<00:00, 1.04it/s]
๐ฆ Download the entire dataset (not for the faint of heart):
>>> r = client.request()
>>> r.download_to_directory("data")
Generating CSV download links...
100%|โโโโโโโโโโ| 40/40 [03:38<00:00, 2.29s/it]
Generated 146,993 CSV links ready for downloading
Downloading CSVs to data...
0%| | 299/146993 [01:50<17:15:06, 2.36it/s]
๐ก Don't forget to get the metadata about the measurement stations:
>>> client.download_metadata("data/metadata.tsv")
Writing metadata to data/metadata.tsv...
๐ Command line interface
$ airbase download --help
Usage: airbase download [OPTIONS]
Download all pollutants for all countries
The -c/--country and -p/--pollutant allow to specify which data to download, e.g.
- download only Norwegian, Danish and Finish sites
airbase download -c NO -c DK -c FI
- download only SO2, PM10 and PM2.5 observations
airbase download -p SO2 -p PM10 -p PM2.5
Options:
-c, --country [AD|AL|AT|...]
-p, --pollutant [k|CO|NO|...]
--path PATH [default: data]
--year INTEGER [default: 2022]
-O, --overwrite Re-download existing files.
-q, --quiet No progress-bar.
--help Show this message and exit.
๐ฃ Roadmap
Parallel CSV downloadsContributed by @avaldebeCLI to avoid using Python all togetherContributed by @avaldebe- Data wrangling module for AirBase output data
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
Built Distribution
File details
Details for the file airbase-0.8.1.tar.gz
.
File metadata
- Download URL: airbase-0.8.1.tar.gz
- Upload date:
- Size: 1.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf00cbe9bbcf7178a70e19b9cf343073f97164bd906057041b23381bb67ed2d0 |
|
MD5 | 3216fc05b05650271cd51a770833051f |
|
BLAKE2b-256 | c27a433f38762d8fca6f6cdd4fdcba32ef00e52168842582a54960bd11d14f5e |
File details
Details for the file airbase-0.8.1-py3-none-any.whl
.
File metadata
- Download URL: airbase-0.8.1-py3-none-any.whl
- Upload date:
- Size: 45.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15e997f671548e2799ba5c661d09b78203e0500273f504530aa804ad1f33f8f4 |
|
MD5 | 21e8b6e951b1519d7b7b14f75c893c1c |
|
BLAKE2b-256 | 29f817b3fda69e3dc4c2f299a478ab254b7756ca25204fa7a40e88ab87ff9115 |