Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Disaster Data Analytics

Recipe 5 — EM-DAT People-Impact Mining

IFRC

What you will learn:

  1. Build CQL2-JSON filters targeting monty:impact_detail.category and monty:impact_detail.type.

  2. Distinguish natural disasters from technological incidents using hazard-code prefixes.

  3. Stream and aggregate impact records with fallback to direct HTTP when pystac-client encounters API quirks.

Step 1 — Import Required Libraries

Step 2 — Configuration

ParameterValue
Collectionemdat-impacts
Year2020
Impact categorypeople
Impact typesdeath
Outputemdat-impacts-2020-deaths.csv
Configuration loaded:
  Year: 2020
  Collection: emdat-impacts
  Impact types: 1
  Output file: emdat-impacts-2020-deaths.csv

Step 3 — Authentication

Connected to: https://montandon-eoapi-stage.ifrc.org/stac
API Title: stac-fastapi

Step 4 — CQL2-JSON Search Function

The search combines four CQL2 predicates: datetime year, impact category, impact type, and a minimum value threshold (> 0).

Search function defined

Step 5 — Natural-Disaster Filter

Montandon hazard codes follow the taxonomy nat-* (natural) vs tec-* (technological). The helper below returns True only when at least one natural code is present and no technological code appears.

Natural disaster filter function defined

Step 6 — Extract Impact Records

Walks every STAC item returned by the search, applies the natural-disaster filter, and flattens the nested monty:impact_detail array into tabular records ready for DataFrame consumption.

Extract function defined

Step 7 — Run the Analysis

Iterates over every people-impact type (deaths, injured, affected, …), performs a CQL2 search for each, filters to natural disasters, and accumulates results into a single CSV output.

======================================================================
EM-DAT 2020 PEOPLE IMPACT ANALYSIS
NATURAL DISASTERS ONLY
======================================================================

Configuration:
  Collection: emdat-impacts
  Year: 2020
  Impact category: people
  Impact types: 1 types
    death
  Filter: Natural disasters only (nat-*)

Output: emdat-impacts-2020-deaths.csv
======================================================================

Searching 1 impact types (natural disasters only)...

death: 286 records

Search completed!
Total records written to CSV: 286
death: 286 records

Search completed!
Total records written to CSV: 286

Step 8 — Results Summary

Displays a ranked table of natural-disaster people-impact totals with percentages, providing a quick overview of relative impact magnitude.


======================================================================
SUMMARY - PEOPLE IMPACTS (NATURAL DISASTERS ONLY)
======================================================================

Search completed in 151.16 seconds
Total records: 286
Natural disasters: 286

======================================================================
PEOPLE IMPACT TOTALS FOR 2020
======================================================================
death               :          15,677 (100.0%)
======================================================================
GRAND TOTAL         :          15,677
======================================================================

Data saved to: emdat-impacts-2020-deaths.csv

Step 9 — Load & Preview Results

Reads the exported CSV back into a pandas DataFrame for interactive exploration and downstream analysis.


Total records in CSV: 286

First 10 records:
Loading...
References
  1. Guha-Sapir, D. (2024). EM-DAT: The Emergency Events Database. Centre for Research on the Epidemiology of Disasters (CRED). https://www.emdat.be
  2. IFRC. (2024). Monty STAC Extension Specification. https://ifrcgo.org/monty-stac-extension/