This project provides a Flask API that serves climate analysis data from an SQLite database. The API is based on a prior analysis of historical weather data in Hawaii, focusing on precipitation, temperature observations, and station metadata.
app.py: The Flask API that serves climate data.climate_starter.ipynb: A Jupyter Notebook that explores the dataset, conducts data analysis, and develops the necessary queries used in the Flask API. It includes:- Database connection and table reflection.
- Data inspection and summary statistics.
- Queries to extract precipitation, station, and temperature data.
- Data visualization using Matplotlib.
hawaii.sqlite: The SQLite database containing the climate data.hawaii_measurements.csv: Raw dataset containing precipitation and temperature readings.hawaii_stations.csv: Raw dataset containing station metadata.
Lists all available API routes.
- Converts the last 12 months of precipitation data into a dictionary
{date: precipitation}. - Returns the JSON representation of the dataset.
- Returns a JSON list of stations from the dataset.
- Queries temperature observations for the most active station over the last 12 months.
- Returns a JSON list of
{date, temperature}.
- For a given start date, calculates TMIN, TAVG, and TMAX for all dates greater than or equal to the start.
- For a given start and end date, calculates TMIN, TAVG, and TMAX between those dates (inclusive).
Ensure you have Python installed. Install the required dependencies with:
pip install flask sqlalchemy numpy pandas dateutilExecute the following command in your terminal:
python app.pyOnce running, open a browser and navigate to:
- Homepage: http://127.0.0.1:5000/
- Precipitation: http://127.0.0.1:5000/api/v1.0/precipitation
- Stations: http://127.0.0.1:5000/api/v1.0/stations
- Temperature Observations: http://127.0.0.1:5000/api/v1.0/tobs
- Temperature Summary (Start Date): http://127.0.0.1:5000/api/v1.0/2017-01-01
- Temperature Summary (Date Range): http://127.0.0.1:5000/api/v1.0/2017-01-01/2017-01-07
- Ensure the database file (
hawaii.sqlite) is in the correct path (Resources/hawaii.sqlite). - Modify the SQLAlchemy engine path in
app.pyif necessary. - You can deploy this API to a cloud platform like Render for remote access.
This project is open-source and available for modification and enhancement.