Cleaning ThinkHazard! data for Brazil
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 directoryThe full script is on GitHub.
License
MIT.