Cleaning ThinkHazard! data for Brazil

Code
R
Climate Hazard
Brazil
R script that downloads and tidies the World Bank ThinkHazard! dataset, filtering eight natural hazard types down to Brazil-specific records for analysis.
Published

November 1, 2025

Modified

November 2, 2025

← Back to Portfolio

Code · R · World Bank ThinkHazard! · Brazil

The World Bank’s ThinkHazard! tool gives researchers a quick read on natural hazard risk — river floods, earthquakes, droughts, cyclones, coastal floods, tsunamis, volcanoes, landslides — for any country or sub-national region. The raw data comes as a multi-sheet Excel file with numeric hazard codes instead of plain names, one worksheet per hazard type. Before any analysis can happen, that needs cleaning.

This script does it in one run.

What it does

The script downloads the full ThinkHazard! dataset from the World Bank’s public portal, reads every worksheet, translates numeric hazard codes into readable names, filters to Brazil records, merges the sheets into a single flat table, and exports a CSV. No API key required.

It was built for the CLIDEWO project, where hazard risk data was the starting layer before modelling how climate exposure intersects with labour conditions in Brazilian agriculture.

Run it

# Dependencies
install.packages(c("readxl", "dplyr", "data.table"))

# Run
source("thinkhazard_cleaning.R")
# → outputs brazil_thinkhazard.csv in the working directory

The full script is on GitHub.

License

MIT.