Skip to main content

A Python package for democratizing access to ambient air pollution data and predictive analytics.

Project description

Environmental Insights

Environmental Insights

Environmental Insights is a Python package for downloading and visualising air pollution concentration data in the UK and globally. Alongside the downloaded data, a set of functions have also been provided to manipulate the air pollution concentrations and explore air pollution futures. The Python package is a companion to the paper entitled "Environmental Insights: Democratizing Access to Ambient Air Pollution Data and Predictive Analytics with an Open-Source Python Package", with the following abstract:
Ambient air pollution is a pervasive issue with wide-ranging effects on human health, ecosystem vitality, and economic structures. Utilizing data on ambient air pollution concentrations, researchers can perform comprehensive analyses to uncover the multifaceted impacts of air pollution across society. To this end, we introduce Environmental Insights, an open-source Python package designed to democratize access to air pollution concentration data. This tool enables users to easily retrieve historical air pollution data and employ a Machine Learning model for forecasting potential future conditions. Moreover, Environmental Insights includes a suite of tools aimed at facilitating the dissemination of analytical findings and enhancing user engagement through dynamic visualizations. This comprehensive approach ensures that the package caters to the diverse needs of individuals looking to explore and understand air pollution trends and their implications.

This is a contituation of the work started in our recently published paper in Environment and Planning B: Urban Analytics and City Science Estimating annual ambient air pollution using structural properties of road networks

Downloading the required data

If you have accessed this work from Github, please read the associated paper that describes the use of this package and its purpose, available here:

Due to Github file size limitations, all of the models and data to use this package have been hosted on Google Drive. The link to the Google Drive folder is: https://drive.google.com/drive/folders/18ZLO8XqtFp3c4WrUJVfSH0fmAXFmL8il?usp=sharing

The Google Drive folder relates to a range of research studies outputs, with the package being designed to be used in conjucntion with the data and models. The easiest manner to integrate the data into the package is to put the corresponding google drive contents into the relevant packaghe folder, the mapping between the two is as follows:

  • environmental_insights_data/air_pollution/uk_complete_set : Data for A Framework for Scalable Ambient Air Pollution Concentration Estimation
  • environmental_insights_data/air_pollution/global_complete_set : Data for A Data-Driven Supervised Machine Learning Approach to Estimating Global Ambient Air Pollution Concentrations With Associated Prediction Intervals
  • environmental_insights_data/feature_vector/uk_typical_day : Data for Environmental Insights
    • This directory contains the data for the feature vectors used to predict the air pollution concentrations across England using the typical day framework proposed in this packages companion paper.
  • environmental_insights_data/feature_vector/supporting_data : Supporting Data for Environmental Insights
    • This directory contains supporting datasets not generated by the research but important to running the tutorial and some other functions of the package.
  • environmental_insights_models/uk : Models/UK
    • This directory contains the data driven supervised machine learning models for England.
  • environmental_insights_models/global : Models/Global
    • This directory contains the data driven supervised machine learning models globally.

Recommended Use

The code has been validated with Python version 3.9.12. You can install a conda environment with this version with the command "conda create -n "environmental_insight_enviro" python=3.9.12". This will install a conda environment with version 3.9.12 for you to use.

  • Step 1: Ensure that jupyter lab is installed. Install instructions are avaliable here.
  • Step 2: Run the code in "package_installation.ipynb" to ensure all of the required packages are avaliable.
  • Step 2: Run through the "tutorial.ipynb" file, which will explain the basic concepts of the package.
  • Step 4: Look through the file in "Documentation" that describe the complete functionality of the package.

The tutorial contains a code snippet that will donwload the required packages for the software via the requirements.txt file. The python packages that are required are:

  • lightgbm (3.3.3)
  • geopandas (0.14.1)
  • pandas (2.1.3)
  • scipy (1.11.4)
  • matplotlib (3.8.2)
  • overpy (0.6)
  • shapely (2.0.2)
  • pyarrow (14.0.1)
  • pyogrio (0.7.2)

While the code may work with other versions of these packages, these packages are the ones testing has been conducted on.

These packages can be installed via code provided in the "package_installation.ipynb" file.

The recommended method of using this package is with a jupyter notebook, which the tutorial for this package is written in. The tutorial is avaliable in the file "tutorial.ipynb". The use of Conda and Jupyter Labs to this end is also recommended.

Aspects of the package

There are three critical components to the package:

  • Data: The data aspects of the work provide access to air pollution concentration data, both in the UK (at a 1kmx1km hourly resolution) and globally (0.25-degree hourly resolution). Further feature vector data is included for both the UK and global models to see the environmental conditions resulting in the model's development and making the predictions it did.
  • Models: The model's aspect of the work provides access to the trained LightGBM models. With the feature vector data, you can predict air pollution concentrations. Further, the feature vectors can be changed to explore hypothetical situations such as "What would happen to the air pollution if the average wind speed doubled on a Friday in June in London?"
  • Functions: A set of supporting functions has been created to simplify the package's use. This includes accessing the data and models, alongside visualisation and making predictions.

All visualisations made through the function within the program are stored within the directory "environmental_insights_visulisations".

Testing

The testing for the package can be found in the "tests" directory making use of the built-in python unittests. To make the use of the tests easier, they are included within the test_workbook.ipynb jupyter notebook.

Documentation

The documentation for the project is included within the directory "Documentation". The documentation provides the overview of the different functions included in the package.

Author

Liam Berrisford

Creating Packages

Pypip

Using python -m build will use the pyproject.toml file to locally build the package and store it within the dist directory. This can then be installed using pip install dist/*.whl. The final dist files can be uploaded to PyPI via twine, using "".

Project details


Download files

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

Source Distribution

environmental_insights-0.2.1b0.tar.gz (72.2 MB view details)

Uploaded Source

Built Distribution

environmental_insights-0.2.1b0-py3-none-any.whl (72.1 MB view details)

Uploaded Python 3

File details

Details for the file environmental_insights-0.2.1b0.tar.gz.

File metadata

File hashes

Hashes for environmental_insights-0.2.1b0.tar.gz
Algorithm Hash digest
SHA256 77ae5b45edbde5cd544353628713a9f3a76416ff1df1a56902ff1990a00a3422
MD5 18c320895b11c56b83410499cf290823
BLAKE2b-256 86db06f69027ce5d7b3ea0693fd1ed5f257b8d45f96fe4bfa4ac5a4c70c50a3c

See more details on using hashes here.

File details

Details for the file environmental_insights-0.2.1b0-py3-none-any.whl.

File metadata

File hashes

Hashes for environmental_insights-0.2.1b0-py3-none-any.whl
Algorithm Hash digest
SHA256 493e74efdf52bfc3e4d8df3886036911ecea8dce788ecb7f465d4fab2a0cce1d
MD5 e24680f1e311d3cb06f9cec7fd3953fd
BLAKE2b-256 2e0092e43947c096a0e1fc79155dc3e8ccee3d0a28e2b648541bc721893bfc00

See more details on using hashes here.

Supported by

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