An interactive dashboard exploring Egypt's emissions trajectory through a climate justice lens
π Live Demo β’ Data Source: Our World in Data β’ AI: OpenRouter β’ Visualizations: Plotly.js
Egypt presents a compelling case of climate injustice β where vulnerability vastly exceeds responsibility.
| Metric | Egypt | Global Average | Implication |
|---|---|---|---|
| COβ per capita | 2.19 t | 4.71 t | 54% below average |
| Global COβ share | 0.64% | β | 1/3 of population share |
| Population | 114 million | β | Growing at ~2M/year |
| GDP per capita | $3,457 (nominal) | β | Developing nation |
- Egypt contributes less than 0.7% of global COβ emissions
- Hosts COP27 (2022)** and committed to 42% renewable electricity by 2035
- One of the world's most climate-vulnerable coastal zones faces sea-level rise
- Despite Zohr gas discovery (2015) making Egypt a net exporter, fossil fuels still account for 90%+ of electricity
Interactive line charts showing Egypt's COβ emissions from 2001-2023 with:
- Total emissions (Mt COβ) with historical phases
- Per capita emissions (t COβ/person) normalized by population
- CAGR calculations for each historical period
Historical Phases:
| Period | Phase | CAGR | Key Events |
|---|---|---|---|
| 2001-2010 | Pre-Arab Spring | +5.4%/yr | Rapid industrialization |
| 2011-2015 | Post-Crisis | +0.6%/yr | Arab Spring, political transition |
| 2016-2019 | Reform & Zohr | -1.5%/yr | Zohr gas online, IMF reform |
| 2020-2023 | COVID & Recovery | +0.5%/yr | Pandemic, global recovery |
Explore emissions by source with a toggle between:
- COβ Mode: Coal, Oil, Gas, Cement, Flaring
- GHG Mode: Full greenhouse gas breakdown including methane (CHβ), nitrous oxide (NβO)
Interactive Timeline Animation: Features an integrated scrubber and playback βΆ controls allowing you to see the exact Donut Chart distribution for any year. As the Donut chart animates, a sweeping timeline synchronizes across the Stacked Area historical series (2001-2023) to show how fuel reliance evolved over two decades!
Key Insight: The Zohr gas field (discovered 2015, online 2017) led to Egypt becoming a net gas exporter by 2019 β explaining the emissions decline during 2016-2019.
Compare Egypt's performance against different country groups across 2001-2023:
| Tier | Countries | Purpose |
|---|---|---|
| Peers | India, Morocco, Pakistan, Indonesia | Similar development stage |
| Regional | Saudi Arabia, Iran, Iraq, South Africa | Geographic neighbors |
| Responsibility | USA, China, Germany, World | Historical emitters |
Four Comparison Charts:
- Per Capita Bar β Sorted descending with world average reference line and dynamic gradient shading
- GDP vs COβ Scatter β Advanced linear scaling with area-proportional population bubbles (sizeref scaling)
- HDI-Adjusted Emissions β COβ per capita / HDI score (live HDI data from UNDP Data API)
- Carbon Intensity β COβ per million USD GDP (using nominal US$ from World Bank API)
Generated using free-tier LLMs via OpenRouter, providing:
- Trend analysis with key drivers
- Country comparison insights
- Emission source breakdown analysis
- Climate justice reflection
Quick reference metrics showing:
- GDP per capita (nominal USD, not PPP)
- vs Global Average (-54% less)
- Share of Global Emissions (0.64%)
flowchart TD
subgraph Backend [Flask Backend]
direction LR
A[app.py<br>Routes] ~~~ B[data_utils.py<br>Data Logic] ~~~ C[ai_service.py<br>OpenRouter API]
end
subgraph LocalCache [Local CSV Cache]
direction LR
D1[(OWID Data<br>owid_emissions.csv)]
D2[(UNDP Data<br>undp_hdi_scores.csv)]
D3[(World Bank Data<br>worldbank_gdp.csv)]
end
subgraph Templates [Jinja2 Templates]
direction LR
E[base.html<br>Layout & CSS] ~~~ F[index.html<br>Dashboard UI]
end
subgraph Frontend [Plotly Frontend]
direction LR
G(Line Charts) ~~~ H(Donut Chart) ~~~ I(Bar Charts) ~~~ J(Scatter Plot)
end
Backend --> LocalCache
Backend --> Templates
Templates --> Frontend
| Component | Technology | Purpose |
|---|---|---|
| Backend | Python Flask | API endpoints, data processing |
| Data (Primary) | Pandas, OWID CSV | Core emissions metrics |
| Data (External API) | requests module |
Dynamic HDI (UNDP HDR API) & Nominal GDP (World Bank API) |
| Frontend | HTML/CSS/JavaScript | Dashboard UI, Animation loops |
| Charts | Plotly.js | Interactive visualizations |
| AI | OpenRouter API | Natural language insights |
| Dev Assistant | Opencode Big Pickle | HTML/CSS/JS implementation |
| Fonts | Plus Jakarta Sans, Outfit, DM Mono | Typography |
| Endpoint | Method | Parameters | Description |
|---|---|---|---|
/ |
GET | β | Main dashboard |
/api/countries |
GET | β | List available countries |
/api/summary/<code> |
GET | code: ISO code |
Country summary |
/api/trend/<code> |
GET | code, metric: co2/ghg |
Trend statistics |
/api/comparison/<code> |
GET | code, tier, year |
Comparison data |
/api/emission-sources/<code> |
GET | code, mode, year |
Source breakdown |
| Endpoint | Method | Parameters | Description |
|---|---|---|---|
/api/ai/trend/<code> |
GET | code, metric |
Trend insight |
/api/ai/comparison/<code> |
GET | code, tier |
Comparison insight |
/api/ai/sources/<code> |
GET | code, mode |
Sources insight |
/api/ai/reflection/<code> |
GET | code |
Climate reflection |
# Get Egypt summary
curl http://localhost:5000/api/summary/EGY
# Get comparison data for 2015
curl "http://localhost:5000/api/comparison/EGY?tier=peers&year=2015"
# Get emission sources in GHG mode
curl "http://localhost:5000/api/emission-sources/EGY?mode=ghg&year=2023"- Python 3.8+
- pip (Python package manager)
-
Clone the repository
git clone <repository-url> cd emission_trend_analysis
-
Create virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Configure environment variables
cp .env.example .env # Edit .env and add your OpenRouter API key (optional, for AI features) -
Run the dashboard
python app.py
-
Open in browser
http://localhost:5000
Create a .env file:
# OpenRouter API Key (optional - AI features won't work without it)
# Get free key at: https://openrouter.ai/
OPENROUTER_API_KEY=your_api_key_here
# UNDP HDR API Key (required for dynamic HDI metric charts)
HDR_API_KEY=HDR-68M2Tq4FVFxNBTfVHszAALekyuaFxQ4u
# Optional: Flask configuration
FLASK_ENV=development
FLASK_DEBUG=1This application is ready to be deployed to Vercel out of the box (configured via vercel.json and app.py).
- Push your repository to GitHub.
- Log into Vercel and click Add New Project.
- Import your GitHub repository.
- Add your
OPENROUTER_API_KEYto the Environment Variables section. - Click Deploy.
| Source | Description | URL |
|---|---|---|
| Our World in Data | COβ & GHG emissions dataset | github.com/owid/co2-data |
| Global Carbon Project | Emissions data provider | globalcarbonproject.org |
| UNFCCC | GHG inventories | unfccc.int |
| Source | Description | Built-In Integration |
|---|---|---|
| World Bank API | GDP per capita (nominal USD) NY.GDP.PCAP.CD |
Data automatically fetched and cached |
| UNDP HDR API | Human Development Index (HDI) | Live fetched tracking for over 190 countries |
| Source | Description |
|---|---|
| IEA | World Energy Outlook 2023 |
| IPCC | AR6 Climate Change 2023 Synthesis Report |
| ICAP | Emissions Trading Worldwide Status Report 2023 |
| UNEP | Emissions Gap Report 2024 |
| CCPI | Climate Change Performance Index 2024 |
- COP27 Host (2022): Egypt hosted the UN Climate Change Conference in Sharm El-Sheikh
- NDC Target: 42% renewable electricity by 2035
- Zohr Gas Field: Discovery (2015) made Egypt a net gas exporter by 2019
- Vulnerability: One of world's most climate-vulnerable coastal zones
| Event | Year | Impact on Emissions |
|---|---|---|
| Arab Spring | 2011 | Political instability, growth slowdown |
| IMF Currency Reform | 2016 | Economic adjustment, energy reforms |
| Zohr Gas Online | 2017 | Natural gas surplus, exports begin |
| COVID-19 | 2020 | Global emissions dip |
| COP27 | 2022 | International climate spotlight |
emission_trend_analysis/
βββ app.py # Flask application & routes
βββ data_utils.py # Data processing functions
βββ ai_service.py # OpenRouter AI integration
βββ requirements.txt # Python dependencies
βββ .env.example # Environment template
β
βββ data/
β βββ cache/
β β βββ owid_emissions.csv # OWID data (cached)
β β βββ undp_hdi_scores.csv # UNDP data (cached)
β β βββ worldbank_gdp.csv # World Bank data (cached)
β βββ fetch_data.ipynb # Data fetching notebook
β βββ analysis.ipynb # Analysis notebook
β βββ countries.ipynb # Country config notebook
β
βββ templates/
β βββ base.html # Base template (CSS, layout)
β βββ index.html # Main dashboard page
β
βββ static/
β βββ egypt_hero.jpg # Hero background image
β
βββ CODE_EXPLANATION.md # Technical documentation
βββ README.md # This file
The dashboard supports two emission views:
- COβ Mode: Only carbon dioxide emissions
- GHG Mode: Full greenhouse gas inventory including methane (CHβ) and nitrous oxide (NβO)
Non-COβ Calculation:
Other GHGs = Total GHG (excl. LUCF) - (Coal + Oil + Gas + Cement + Flaring)
Calculated using GWP100 metric via OWID/IPCC methodology.
This metric combines COβ per capita with Human Development Index to assess climate justice:
HDI-Adjusted = COβ per capita / HDI Score
Lower values = more efficient human development per unit of COβ
Example values (2023):
| Country | COβ/capita | HDI | Adjusted |
|---|---|---|---|
| Egypt | 2.19 | 0.731 | 3.0 |
| India | 2.13 | 0.645 | 3.3 |
Compound Annual Growth Rate calculated from actual data:
CAGR = (End Value / Start Value)^(1/years) - 1
Not hardcoded estimates β computed from OWID time series data.
- Update
data_utils.pywith country code and HDI score - Add to
TIER_COMPARISONSfor comparison groups - Create country description in
index.htmlcountryDescriptionsobject
All Plotly charts use a shared configuration (PB object) in index.html:
const PB = {
paper_bgcolor: 'rgba(0,0,0,0)',
plot_bgcolor: 'rgba(0,0,0,0)',
font: { family: 'Plus Jakarta Sans', ... },
margin: { t: 16, r: 16, b: 48, l: 56 },
// ...
};The AI service uses free-tier models via OpenRouter. Rate limiting (2-second intervals) prevents API overuse. Prompts are optimized for concise, actionable insights.
This project is for educational and research purposes. Data sourced from Our World in Data under their license terms, and Human Development Index data from the United Nations Development Programme (UNDP).
- Main Data: Our World in Data - Global Carbon Project
- HDI Data: United Nations Development Programme (UNDP) - Human Development Index & PHDI
- AI: OpenRouter - Free tier LLM access for dashboard insights
- AI Development Assistant: Opencode Big Pickle - Used for HTML, CSS, and JavaScript implementation assistance
- Visualizations: Plotly
- Fonts: Google Fonts - Plus Jakarta Sans, Outfit, DM Mono
Built for TISS Mumbai - Climate Change, Sustainability & Development Assignment
