Skip to content

TayyabManan/WaterTrace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

38 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒŠ WaterTrace: Pakistan Groundwater Monitoring System

Pakistan Groundwater Monitoring

๐Ÿ“‹ Overview

WaterTrace is a comprehensive groundwater monitoring and analysis system for Pakistan, leveraging 22 years of satellite data (2002-2024) to track and predict water resource changes. This project combines advanced remote sensing data from GRACE satellites and GLDAS models with machine learning to provide actionable insights into Pakistan's critical water crisis.

๐ŸŽฏ Key Features

  • Real-time Dashboard: Interactive web application displaying groundwater trends and predictions
  • Multi-Source Data Integration: Combines GRACE satellite data (2002-2017) with GLDAS soil moisture data (2018-2024)
  • Machine Learning Predictions: Advanced models trained on historical data for future trend analysis
  • District-Level Analysis: Detailed groundwater mapping across 145 districts in Pakistan
  • Responsive Design: Fully responsive interface optimized for all devices

๐Ÿšจ Critical Findings

Our analysis reveals a severe water crisis in Pakistan:

  • ๐Ÿ“‰ Historical Depletion (2002-2017): -13.71 cm total groundwater loss
  • ๐Ÿ“Š Annual Decline Rate: -0.81 cm/year consistent depletion
  • ๐Ÿ”„ Recent Trends (2018-2024): Slight stabilization indicated by GLDAS data (+1.5 kg/mยฒ/year)
  • โš ๏ธ Critical Regions: Quetta (-15.3 cm), Lahore (-12.5 cm), and Punjab agricultural belt showing severe stress

Historical Analysis

๐Ÿ› ๏ธ Technology Stack

Backend

  • Cloudflare Workers: Ultra-fast edge API (migrated from Flask)
  • TypeScript: Type-safe API development
  • Embedded Data: Zero-latency data access
  • Global CDN: <50ms response times worldwide
  • Google Earth Engine: Satellite data processing

Frontend

  • React 18: Modern UI framework
  • Recharts: Data visualization
  • Leaflet: Interactive mapping
  • Tailwind CSS: Responsive styling
  • Vercel: Production hosting

Data Sources

  • GRACE Satellites: NASA/DLR gravity anomaly measurements
  • GLDAS: NASA/NOAA land surface model outputs
  • Pakistan Shapefiles: Official administrative boundaries

๐Ÿ“Š Data Pipeline

Dataset Timeline

1. Data Collection

  • GRACE data: Monthly groundwater anomalies (2002-2017)
  • GLDAS data: 3-hourly soil moisture aggregated to monthly (2018-2024)
  • Spatial resolution: District-level aggregation for Pakistan

2. Data Processing

# Example processing pipeline
- Temporal aggregation to monthly averages
- Spatial clipping to Pakistan boundaries
- Unit conversion and normalization
- Anomaly calculation from baseline

3. Machine Learning Pipeline

  • Feature engineering with seasonal indicators
  • Model comparison: Linear Regression, Random Forest, Gradient Boosting
  • Time series validation with 80/20 split
  • Performance metrics: Rยฒ = 0.89, RMSE = 0.67 cm

GLDAS Analysis

๐Ÿ—บ๏ธ Interactive Features

The interactive map displays:

  • Color-coded markers indicating groundwater stress levels
  • District-wise statistics and trends
  • Real-time data updates
  • Mobile-responsive interface

Time Series Visualization

  • Complete 22-year timeline with data source indicators
  • Seasonal pattern analysis
  • Trend lines and statistical summaries
  • Export capabilities for further analysis

๐Ÿ“ˆ Analysis Results

Statistical Summary

Statistical Summary

Key Metrics:

  • Average groundwater anomaly: -7.6 cm (current estimate)
  • Seasonal variation: ยฑ3.2 cm
  • Most stressed province: Balochistan
  • Recovery potential: Limited without intervention

Provincial Distribution

Provincial Analysis

๐Ÿš€ Installation & Setup

Prerequisites

  • Python 3.11+
  • Node.js 16+
  • Git

Backend Setup (Cloudflare Workers)

# Clone repository
git clone https://github.com/TayyabManan/WaterTrace.git
cd WaterTrace/webapp/cloudflare-api

# Install dependencies
npm install

# Deploy to Cloudflare Workers
npm run deploy

# For local development
npm run dev

Frontend Setup

# Navigate to frontend
cd ../frontend

# Install dependencies
npm install

# Start development server
npm start

Configuration

Update frontend/src/config.js:

// Production API (Cloudflare Workers)
const API_URL = 'https://watertrace-api.watertrace.workers.dev';

๐Ÿ“š API Documentation

Base URL

Production: https://watertrace-api.watertrace.workers.dev
Development: http://localhost:8787

Endpoints

Analysis Summary

GET /api/analysis/summary

Returns project overview and key statistics

Historical Time Series

GET /api/historical/timeseries

Returns GRACE data (2002-2017)

Recent Time Series

GET /api/recent/timeseries

Returns GLDAS data (2018-2024)

Combined Timeline

GET /api/combined/timeline

Returns merged and scaled data for visualization

District Groundwater Data

GET /api/districts/groundwater

Returns GeoJSON with district-level statistics

GLDAS Trend Analysis

GET /api/gldas/trend-analysis

Returns trend analysis and predictions

๐ŸŒ Live Demo

Performance Improvements (Cloudflare Workers vs Render)

  • Response Time: 5-10s โ†’ <50ms (200x faster)
  • Cold Starts: Eliminated
  • Global Availability: Edge deployment in 200+ cities
  • Uptime: 99.99% SLA

๐Ÿ“Š Research Methodology

Data Sources

  1. GRACE (2002-2017)

    • Direct groundwater measurements via gravity anomalies
    • Monthly temporal resolution
    • ~300km spatial resolution
  2. GLDAS (2018-2024)

    • Deep soil moisture as groundwater proxy
    • 0.25ยฐ spatial resolution
    • 3-hourly temporal resolution aggregated to monthly

Analysis Techniques

  • Time Series Decomposition: Trend, seasonal, and residual components
  • Statistical Testing: Mann-Kendall trend test, p-value < 0.001
  • Machine Learning: Ensemble methods for prediction
  • Spatial Analysis: District-level aggregation and interpolation

๐Ÿ”ฎ Future Enhancements

  1. GRACE-FO Integration: Incorporate latest GRACE Follow-On mission data
  2. Real-time Alerts: District-wise water stress notifications
  3. Climate Integration: Correlation with precipitation and temperature data
  4. Policy Dashboard: Decision support system for water managers
  5. Mobile App: Native applications for field monitoring

๐Ÿค Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is part of the academic research portfolio. All rights reserved.

๐Ÿ‘จโ€๐Ÿ’ป Author

Tayyab Manan

๐Ÿ™ Acknowledgments

  • GRACE Mission: NASA/DLR for providing groundwater data
  • GLDAS System: NASA/NOAA for land surface models
  • Google Earth Engine: For cloud-based geospatial analysis
  • Pakistan Survey Department: For administrative boundaries

๐Ÿ“ž Contact

For questions, suggestions, or collaborations:


๐ŸŒŠ Monitoring Pakistan's Water Future, One Drop at a Time ๐ŸŒŠ

Groundwater Anomalies

Together, we can work towards sustainable water management for Pakistan's future generations.