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 3 — Multi-Source Hazard Analysis & Visualisation

IFRC

What you will learn:

  1. Build reusable helper functions (search_stac, stac_items_to_dataframe).

  2. Perform temporal and spatial exploratory analysis.

  3. Compare hazard-code frequency across data sources with stacked bar charts.

  4. Render an interactive Folium map colour-coded by hazard type and source.

Environment Setup

Binder
Google Colab
Local

All dependencies are pre-installed. Click Launch Binder at the top of the page — no setup needed.

Step 1 — Imports and API Connection

======================================================================
AUTHENTICATION REQUIRED
======================================================================

The Montandon STAC API requires a Bearer Token for authentication.

How to get your token:
  1. Visit: https://goadmin-stage.ifrc.org/
  2. Log in with your IFRC credentials
  3. Generate an API token from your account settings

Alternatively, set the MONTANDON_API_TOKEN environment variable:
  PowerShell: $env:MONTANDON_API_TOKEN = 'your_token_here'
  Bash: export MONTANDON_API_TOKEN='your_token_here'

======================================================================

✓ Connected to: https://montandon-eoapi-stage.ifrc.org/stac
✓ Authentication: Bearer Token (OpenID Connect)
✅ PySTAC helper function initialized (using client.search())

Step 2 — Reusable Helper Functions

Two functions power this recipe:

FunctionPurpose
search_stac()Wraps client.search() with optional CQL2, bbox, and datetime parameters
stac_items_to_dataframe()Flattens STAC items into a tidy DataFrame
DataFrame conversion function created

Step 3 — Convert STAC Items to a DataFrame

The stac_items_to_dataframe() function:

  • Extracts base fields (id, collection_id, geometry_type).

  • Parses geographic coordinates from Point geometries.

  • Flattens nested properties (e.g., monty:hazard_detail.severity_value).

DataFrame created with 50 rows and 20 columns

Column names:
['id', 'collection_id', 'geometry_type', 'longitude', 'latitude', 'roles', 'title', 'datetime', 'keywords', 'description', 'end_datetime', 'monty:etl_id', 'severitydata.severity', 'severitydata.severitytext', 'severitydata.severityunit', 'monty:corr_id', 'start_datetime', 'monty:hazard_codes', 'monty:country_codes', 'monty:episode_number']
Loading...

Step 4 — Exploratory Data Analysis

Basic Dataset Statistics:

        longitude   latitude  severitydata.severity  monty:episode_number
count   50.000000  50.000000              50.000000          5.000000e+01
mean    47.191573  15.212496             262.368000          8.046509e+05
std    125.001690  32.647875            1304.252939          8.460090e+05
min   -177.559200 -58.808900               4.500000          1.000000e+00
25%    -68.671400 -15.793174               4.700000          1.000000e+00
50%    124.048850  18.309500               5.000000          1.000000e+00
75%    142.850200  41.042325               5.275000          1.676376e+06
max    179.972700  62.195700            7834.000000          1.676468e+06

4. Hazard Code Descriptions

Define mappings for hazard codes used across different disaster data standards (GDACS, EM-DAT, UNDRR-ISC).

Hazard code descriptions loaded

4.1 Temporal Analysis

Analyzing when disasters occur by year and month to identify patterns and trends.

Events by Year:

year
2025    50
Name: count, dtype: int64
<Figure size 1500x500 with 2 Axes>

5. Data Export

Export the full dataset to CSV format for use in spreadsheet applications or other analysis tools.

5.1 CSV Export

Subset exported to gdacs_events_subset.csv
   Columns: ['id', 'collection_id', 'datetime', 'monty:country_codes', 'monty:hazard_codes', 'monty:corr_id']

Sample data:
                    id collection_id              datetime  \
0  gdacs-event-1514353  gdacs-events  2025-12-10T08:27:06Z   
1  gdacs-event-1514350  gdacs-events  2025-12-10T07:42:55Z   
2  gdacs-event-1514341  gdacs-events  2025-12-10T06:38:27Z   
3  gdacs-event-1514332  gdacs-events  2025-12-10T05:18:49Z   
4  gdacs-event-1514294  gdacs-events  2025-12-09T23:19:52Z   

  monty:country_codes             monty:hazard_codes  \
0               [COL]  [GH0101, EQ, nat-geo-ear-gro]   
1               [IDN]  [GH0101, EQ, nat-geo-ear-gro]   
2               [CHL]  [GH0101, EQ, nat-geo-ear-gro]   
3                  []  [GH0101, EQ, nat-geo-ear-gro]   
4               [RUS]  [GH0101, EQ, nat-geo-ear-gro]   

                      monty:corr_id  
0  20251210-COL-GH0101-1676468-GCDB  
1  20251210-IDN-GH0101-1676464-GCDB  
2  20251210-CHL-GH0101-1676453-GCDB  
3     20251210--GH0101-1676442-GCDB  
4  20251209-RUS-GH0101-1676432-GCDB  

6. Multi-Collection Hazard Code Analysis

This section analyzes the top 10 most common hazard codes across multiple data sources (GDACS, EM-DAT, GLIDE) to:

  1. Count how many times each hazard code appears

  2. Compare hazard code distribution across different collections

  3. Identify which disaster types are most common

  4. Visualize the results with detailed charts

This helps us understand:

  • Which disaster types are most frequently recorded

  • How different data sources classify the same disasters

  • The overall distribution of hazard events in the database

Hazard Code Analysis

Analyzing hazard codes from multiple data sources...

Collections to analyze: gdacs-events, glide-events

  gdacs-events: 100 items retrieved
  glide-events: 100 items retrieved

================================================================================
HAZARD CODE COUNTS
================================================================================

Top 10 Hazard Code Counts:

    Hazard Code            Description  Total Count  GDACS  EM-DAT  GLIDE
         GH0101 Earthquake (UNDRR-ISC)           96     93       0      3
             EQ             Earthquake           96     93       0      3
nat-geo-ear-gro    Earthquake (EM-DAT)           96     93       0      3
         GH0001                Unknown           24      0       0     24
         GH0002                Unknown           24      0       0     24
         GH0003                Unknown           24      0       0     24
         GH0004                Unknown           24      0       0     24
         GH0005                Unknown           24      0       0     24
nat-hyd-flo-flo      Flooding (EM-DAT)           21      0       0     21
         MH0030                Unknown           18      0       0     18
<Figure size 1400x700 with 1 Axes>

================================================================================
Total Events: 447
Unique Hazard Codes Displayed: 10 (out of 43 total)

8. Interactive Map Visualization

Create an interactive map showing disaster locations in Europe for the last 3 months across multiple collections (GDACS, EM-DAT, GLIDE).

Folium already installed

Total events found: 71
Extracted 23 unique hazard types from 71 events
Map created with 71 events
Hazard types on map: Drought, Earthquake, Flood, Forest fires
Sources: gdacs-events, emdat-events, glide-events
Loading...
References
  1. European Commission Joint Research Centre. (2024). Global Disaster Alert and Coordination System (GDACS). https://www.gdacs.org
  2. Guha-Sapir, D. (2024). EM-DAT: The Emergency Events Database. Centre for Research on the Epidemiology of Disasters (CRED). https://www.emdat.be
  3. Asian Disaster Reduction Center. (2024). GLobal IDEntifier Number (GLIDE). https://glidenumber.net