Rainfall Dynamics in Uganda: A District-Level Analysis for 2021

Author
Affiliation

Haron Otim

Published

February 16, 2024

Abstract
This project employs advanced data analysis to investigate rainfall dynamics across different districts in Uganda for the year 2021. Focusing on distinct regions, the study aims to uncover historical patterns, disparities, and correlations with socio-economic and environmental variables. Utilizing the R programming language, the project provides valuable insights for policymakers, environmental planners, and researchers. The findings contribute to evidence-based decision-making for sustainable development and hold significance for addressing environmental challenges and guiding strategic interventions in Uganda’s diverse districts.

Project Description

This project endeavors to investigate and comprehend the dynamic patterns of rainfall distribution across different districts in Uganda for the year 2021. The central objective is to employ advanced data analysis techniques and time series modeling to reveal trends, variations, and potential influencing factors affecting rainfall patterns.

Objectives:

Introduction

The data for this study was acquired from the Uganda Beaureau of Statistics, specifically focusing on climate data for rainfall amounts received by selected districts in 2021.

It is important to note that the analysis conducted serves an academic purpose only.

Understanding the nuances of rainfall distribution in different districts of Uganda is crucial for informed decision-making and sustainable development as narrated by (Burton, Malone, and Huq 2005). This analysis, focused on distinct districts, aims to provide valuable insights into local precipitation patterns, environmental trends, and the impact of various factors on rainfall distribution. The outcomes of this study can guide policy interventions, infrastructure planning, and strategic decision-making to ensure balanced regional growth and address environmental challenges.

The project employs statistical analysis, time series modeling, and data visualization techniques using the R programming language. This comprehensive approach integrates data from various sources, offering a holistic view of the factors influencing rainfall patterns in Uganda. The results aim to facilitate evidence-based decision-making for policymakers, researchers, and stakeholders involved in the sustainable development of the region.

Methods

Raw Data Import

Code
# Importing the selected data frame
library(readxl)
Monthly_rainfall_for_selected_centres_in_mm_2021 <- read_excel("/cloud/project/data/raw/Monthly_rainfall_for_selected_centres_in_mm_2021.xlsx", 
    range = "B3:N23")

Data cleaning

The district of Wakiso was mistakenly registered twice in the raw data. For the purpose of a more representative analysis, one of the obersvations was allocated to Apac District, my home District.

Code
Monthly_rainfall_for_selected_centres_in_mm_2021 <-   Monthly_rainfall_for_selected_centres_in_mm_2021 |> 
  mutate(District = case_when(
    Jan == 154.4 ~ "Apac",
    .default = District
  ))

Data transformation

For easier analysis of this dataset, the data was pivoted with a new variable months.

Code
monthly_rainfall <- Monthly_rainfall_for_selected_centres_in_mm_2021 |>
  pivot_longer(cols = Jan:Dec,
               names_to = "months",
               values_to = "rainfall_in_mm")

Processed Analysis ready data

Code
# storing analysis ready data as a .csv file
write_csv(monthly_rainfall, "/cloud/project/data/processed/monthly_rainfall_processed.csv")

Monthly rainfall for selected districts of Lira, Arua and Jinja.

Code
# monthly rainfall extracted for Arua, Lira and Jinja districts
library(readr)
monthly_rainfall_processed <- read_csv("/cloud/project/data/processed/monthly_rainfall_processed.csv")

monthly_rainfall_arua_lira_and_Jinja <- monthly_rainfall_processed |>
  filter(District %in% c("Arua", "Lira", "Jinja"))

Data Exploration

Figure 1 is a scatter diagram showing the rainfall amounts received by different districts in the month of january 2021 in Uganda.

Code
  ggplot(data = Monthly_rainfall_for_selected_centres_in_mm_2021,
       mapping = aes(x = Jan,
                     y = District,
                     color = District)) +
  geom_point() + 
  labs(x = "Rainfall received in January (mm)", y = "Districts")

Figure 1: Rainfall Distribution in different districts in January

Choices for graphs used in visualization

  1. Bar Charts:

    • For comparing total annual rainfall amounts or monthly variations among different districts, providing a clear visual comparison.

      Code
      monthly_rainfall_arua_lira_and_Jinja |>
        ggplot(mapping = aes(x = fct_reorder(months, case_when(months == "Jan" ~ 1,
                                                               months == "Feb" ~ 2,
                                                               months == "Mar" ~ 3,
                                                               months == "Apr" ~ 4,
                                                               months == "May" ~ 5,
                                                               months == "Jun" ~ 6,
                                                               months == "Jul" ~ 7,
                                                               months == "Aug" ~ 8,
                                                               months == "Sep" ~ 9,
                                                               months == "Oct" ~ 10,
                                                               months == "Nov" ~ 11,                                                             months == "Dec" ~ 12)),
                             y = rainfall_in_mm)) +
        geom_col() +
        facet_wrap(~District) +
         labs(title = "Monthly Rainfall Across Districts in 2021",
             x = "Month",
             y = "Rainfall (mm)") +
        theme_minimal() +
        theme(axis.text.x = element_text(size = 8, angle = 90, hjust = 1),
              strip.text = element_text(size = 10),
              strip.background = element_blank(),
              plot.title = element_text(size = 14, face = "bold"))

Results

  1. Spatial and Temporal Patterns:

    • Identification and description of spatial and temporal patterns in rainfall distribution across districts.

      Code
      ggplot(data = monthly_rainfall,
             aes(x = months,
                 y = rainfall_in_mm)) +
        geom_col() +
        facet_wrap(~District, ncol = 4) +
        labs(title = "Monthly Rainfall Across Districts in 2021",
             x = "Month",
             y = "Rainfall (mm)") +
        theme_minimal() +
        theme(axis.text.x = element_text(size = 8, angle = 90, hjust = 1),
              strip.text = element_text(size = 10),
              strip.background = element_blank(),
              plot.title = element_text(size = 14, face = "bold"))

  2. Total Annual Rainfall:

    • The Table 1 below shows total annual rainfall amounts for each district, providing an overview of regional variations.

      Code
      library(gt)
      
      total_annual_rainfall <- monthly_rainfall |>
        group_by(District) |> 
        summarize(total_annual_rainfall = sum(rainfall_in_mm))
      total_annual_rainfall|> 
        gt() |> 
        fmt_number(columns = c(total_annual_rainfall),
                   decimals = 1)
      Table 1:

      A table showing the total annual rainfall received in different districts in 2021

      District total_annual_rainfall
      Apac 1,369.9
      Arua 1,279.0
      Bulambuli 1,911.0
      Gulu 1,678.8
      Jinja 1,628.9
      Kabale 953.3
      Kampala 1,674.8
      Kasese 918.3
      Kitgum 1,361.2
      Kotido 822.6
      Lira 1,024.7
      Masindi 1,076.6
      Mbarara 933.2
      Mubende 1,028.0
      Rakai 1,202.7
      Serere 1,119.9
      Soroti 1,060.3
      Ssembabule 948.1
      Tororo 1,538.0
      Wakiso 1,399.0
  3. Monthly Rainfall Variations:

    • The Table 2 below shows analysis of monthly variations in rainfall, identifying peak months and dry periods in the districts of Arua, Lira and Jinja as case studies.

      Code
      # Define the thresholds for high, medium, and low rainfall rates
      high_threshold <- 150  # mm/h
      medium_threshold <- 50  # mm/h
      
      # Categorize the rainfall values
      monthly_rainfall_category <- monthly_rainfall_arua_lira_and_Jinja |> 
        mutate(rainfall_cat = case_when(
          rainfall_in_mm > high_threshold ~ "high",
          rainfall_in_mm > medium_threshold ~ "medium",
          TRUE ~ "low"
        ))
      
      monthly_rainfall_category |> 
        pivot_wider(names_from = months,
                    values_from = rainfall_in_mm) |> 
        gt() |> 
        tab_header(
          title = "Monthly Rainfall by District and Category",
          subtitle = "Data from 2021")
      Table 2:

      A table showing the variations of rainfall received in case study districts throughout the year

      Monthly Rainfall by District and Category
      Data from 2021
      District rainfall_cat Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
      Arua low 0.0 0.2 NA NA NA NA NA NA NA NA NA 7.9
      Arua medium NA NA 71.1 57.7 146.3 113.8 NA 125.2 NA NA 147.5 NA
      Arua high NA NA NA NA NA NA 197.1 NA 171.5 240.7 NA NA
      Jinja high 154.8 NA 220.5 333.2 151.4 NA NA 156.2 NA NA NA 161.4
      Jinja low NA 27.4 NA NA NA 46.6 48.9 NA NA NA NA NA
      Jinja medium NA NA NA NA NA NA NA NA 119.4 144.8 64.3 NA
      Lira low 5.0 14.4 NA NA NA NA NA NA NA NA 37.0 3.4
      Lira medium NA NA 75.5 143.5 112.5 NA 86.0 95.8 NA 127.7 NA NA
      Lira high NA NA NA NA NA 156.2 NA NA 167.7 NA NA NA

Conclusions

  • According to Figure 1, Jinja and Apac districts receive extremely high amounts of rainfall in January as compared to the others. This calls for the responsible authorities assess the vulnerability of infrastructure and communities: Identify critical infrastructure, such as roads, bridges, and water systems, that are at risk during extreme rainfall events. Also, evaluate the socio-economic and demographic characteristics of the district’s population to understand their vulnerability to extreme rainfall events.

  • According to , Kotido District receives the least amount of rainfall in the whole year, it is therefore important to emphasize the importance of water conservation and efficient irrigation techniques to ensure sustainable agricultural practices as backed by (Evans and Sadler 2008).

  • According to, Bulambuli District receives the highest amount of rainfall in the whole year, it is paramount to support the development of climate-resilient infrastructure, such as improved drainage systems and flood-control measures, to mitigate the impacts of extreme rainfall events.

  • According to Table 2, Arua district receives consistently moderate rainfall between March to June and Lira District between March and May; this is suitable for agricultural purpose as extreme values of low or high rainfall amounts may cause crop failure according to a study by (Porter and Semenov 2005).

References

Burton, Ian, Elizabeth Malone, and Saleemul Huq. 2005. Adaptation Policy Frameworks for Climate Change: Developing Strategies, Policies and Measures. Cambridge University Press.
Evans, Robert G., and E. John Sadler. 2008. “Methods and Technologies to Improve Efficiency of Water Use.” https://onlinelibrary.wiley.com/doi/abs/10.1029/2007WR006200.
Porter, John R, and Mikhail A Semenov. 2005. “Crop Responses to Climatic Variation.” https://doi.org/10.1098/rstb.2005.1752.