WeatherInsight is a Python-based application that allows users to scrape, manage, and visualize weather data for specified date ranges. The application features a menu-driven interface to facilitate easy interaction.
- Download Weather Data: Fetch a complete dataset for a predefined range of years.
- Update Weather Data: Update the database with missing weather data, ensuring no duplication.
- Visualize Data:
- Generate a Box Plot for a specified year range.
- Generate a Line Plot for a specified month and year.
- Menu-Driven Interface: Intuitive and user-friendly navigation.
Ensure you have the following installed:
- Python 3.7 or higher
- pip (Python package manager)
- SQLite (for database management)
- Clone the repository:
git clone https://github.com/PhillipJBridgeman/WeatherInsight.git
cd WeatherInsight- Create a virtual environment and activate it:
python -m venv venv
.\venv\Scripts\activate # On Windows
# source venv/bin/activate # On macOS/Linux- Install required dependencies:
pip install -r requirements.txt- Ensure sqlite3 is installed and available in your system PATH:
- Verify by running:
sqlite3 --versionRun the application by executing weather_processor.py:
python weather_processor.py- Download Weather Data (Full Range):
- Fetch a complete dataset for the predefined range of years (2020 to the current year).
- Automatically save the data to the SQLite database.
- Update Weather Data (Latest to Current):
- Check the database for the latest available weather data.
- Fetch and save missing weather data from the last recorded date to today.
- Visualize Data: Box Plot (Year Range):
- Enter a start and end year to generate a box plot of average temperatures for the selected range.
- Visualize Data: Line Plot (Month & Year):
- Enter a specific month and year to generate a line plot of daily average temperatures for the chosen period.
- Exit Program:
- Exit the application.
WeatherInsight/
├── dbcm.py # Database context manager
├── db_operations.py # Handles database operations (save, fetch, update)
├── plot_operations.py # Generates data visualizations (box and line plots)
├── requirements.txt # Project dependencies
├── scrape_weather.py # Web scraping logic
├── weather_processor.py # Main entry point for the application
└── weather_data.db # SQLite database file (generated on first run)The SQLite database (weather_data.db) contains a single table:
| Column | Type | Description |
|---|---|---|
| id | INTEGER | Primary key (auto-increment) |
| sample_date | TEXT | Date of the weather record |
| location | TEXT | Location of the weather data |
| min_temp | REAL | Minimum temperature (°C) |
| max_temp | REAL | Maximum temperature (°C) |
| avg_temp | REAL | Average temperature (°C) |
python weather_processor.py- Select 1 to download the full dataset:
Enter your choice: 1
Starting download of full weather data...
Scraping completed. Saving data to the database...
Data downloaded and saved successfully!- Select 2 to update weather data:
Enter your choice: 2
Updating weather data...
Fetching data from 2024-11-30 to 2024-12-01...
Weather data updated successfully!- Select 3 to generate a box plot:
Enter your choice: 3
Enter the year range for the box plot:
Start year: 2020
End year: 2024
Generating box plot for the range 2020–2024...
Box plot generated successfully!- Select 4 to generate a line plot:
Enter your choice: 4
Enter the month and year for the line plot:
Year: 2024
Month (1–12): 12
Generating line plot for 12/2024...
Line plot generated successfully!Contributions are welcome! Follow these steps:
- Fork the repository
- Create a new feature branch:
git checkout -b feature-branch-name- Commit your changes:
git commit -m "Add your message here"- Push to your branch:
git push origin feature-branch-name- Open a Pull Request on GitHub.
This project is licensed under the MIT License. See the LICENSE file for details.
- Weather data is sourced from Environment Canada.
- Developed as part of the Business Information Technology program at Red River College Polytechnic.