Skip to content

A Python-based tool designed to fetch real-time Air Quality Index (AQI) data for any specified city and generate a vivid landscape image representing the current air quality conditions and overlay with City Name and AQI.

License

Notifications You must be signed in to change notification settings

jatinkrmalik/aqi-visualizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AQIVisualizer

AQIVisualizer is a command-line Python application that fetches the Air Quality Index (AQI) data for a specified city and generates a landscape image that artistically represents the current air quality conditions. The tool uses environmental data APIs and OpenAI's image generation capabilities to overlay the AQI value on the image in a hyper-realistic style.

For example:

image

image

image

Features

  • Fetch real-time AQI data for any specified city.
  • Generate a hyper-realistic image of the city's landmark with an AQI representation.
  • Customize the text overlay on the generated image.
  • Command-line arguments for easy customization.
  • Save the final image to a specified path.

Prerequisites

Before you begin, ensure you have met the following requirements:

  • Python 3.6 or higher installed on your machine.
  • An active internet connection to fetch data from APIs and generate images.
  • API keys for OpenAI and AQICN services.

Project Structure

The project is organized into the following modules under ./src:

  • aqi_api.py: Handles the fetching of AQI data from the environmental data API.
  • image_generator.py: Manages the generation of images and the addition of text overlays.
  • cli.py: Contains the command-line interface logic for accepting user inputs.
  • utils.py: Provides utility functions such as logging setup.
  • main.py: Serves as the entry point to the application, orchestrating the flow between modules

Installation

To install AQIVisualizer, follow these steps:

  1. Clone the repository or download the source code to your local machine.

  2. Navigate to the project directory.

  3. Install the required Python dependencies:

    pip install -r requirements.txt
  4. Set up your API keys as environment variables:

    export OPEN_AI_TOKEN=<your_openai_token>
    export AQICN_TOKEN=<your_aqicn_token>

    Replace <your_openai_token> and <your_aqicn_token> with your actual OpenAI and AQICN API keys, respectively.

    Get your AQI Token from here.

Usage

To use AQIVisualizer, you can run the script with optional command-line arguments. Here's how you can execute the script:

python src/main.py --city "City Name" --text "Custom Text Overlay" --output "path/to/save/image"

Example: