# Set chunk options
knitr::opts_chunk$set(echo = TRUE)Ireland’s Median Rainfall in January 1850-2014
1.Creating a map of rainfall in Ireland for the 25 weather stations, colour coding the symbol for each station according to its median rainfall level in January.
Introduction
Rainfall is an essential climatic variable that influences agriculture, water management, and ecosystems. This project visualizes the median rainfall for January across 25 weather stations in Ireland. Using Rainfall data, created an interactive map that highlights regional rainfall patterns by color-coding stations based on their median rainfall levels. This visualization offers valuable insights into Ireland’s climatic conditions and rainfall distribution.By leveraging geospatial mapping techniques, we can analyze rainfall distribution effectively across various locations.The data contains information about the station’s rainfall per month from the years 1850 to 2014.
Objectives
1.To visualize median rainfall distribution in January across 25 weather stations in Ireland .
2.To leverage geospatial mapping to provide an interactive representation of rainfall data.
3.To identify areas with high and low median rainfall for further climatic and agricultural analysis.
Methodology
Data Preparation:
Rainfall data was preprocessed to compute the median rainfall for the month of January across all stations. Station coordinates (latitude and longitude) were merged with rainfall data for geospatial visualization.
Geospatial Mapping:
Leaflet was used to create an interactive map.
Rainfall data was represented using circle markers, with sizes and colors scaled to rainfall values.
Visualization Enhancements:
Added dynamic legends and tooltips for an intuitive user experience.
Used a visually appealing color palette (viridis) to enhance readability.
Data Preparation
Loading Required Libraries
We use the following libraries:
tidyversefor data manipulation.leafletfor creating interactive maps.RColorBrewerfor color schemes.spfor handling spatial data.
# Load necessary libraries
library(tidyverse)── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.5
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.5.1 ✔ tibble 3.2.1
✔ lubridate 1.9.3 ✔ tidyr 1.3.1
✔ purrr 1.0.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(leaflet)Warning: package 'leaflet' was built under R version 4.4.2
library(RColorBrewer)
library(sp)Warning: package 'sp' was built under R version 4.4.2
library(dplyr)Loading and Preparing the Dataset
The dataset contains rainfall observations for 25 weather stations in Ireland. Each observation includes the station name, geographical coordinates, and monthly rainfall values.
This code ensures that station names are cleaned by removing any leading or trailing spaces from both the stations and rain datasets. It then filters the rainfall data for the month of January and calculates the median rainfall for each station.
setwd("C:/Users/DEEPASRI/OneDrive/Documents/personal/Master studies/Maynooth -PG/SEM 1/geocomp")
load("rainfall.RData")
# Ensured station names in both datasets are clean
stations$Station <- trimws(stations$Station)
rain$Station <- trimws(rain$Station)
# Filtered and calculated median rainfall for January by station
med_rain <- rain %>%
filter(Month == "Jan") %>%
group_by(Station) %>%
summarise(Median_Rainfall = median(Rainfall, na.rm = TRUE))Merging the rainfall data with the station coordinates
This code merges the median rainfall data with the station coordinates by performing an inner join on the “Station” column, ensuring that only the stations present in both datasets are included in the merged result.
# Merged the median rainfall data with station coordinates
merged_data <- med_rain %>%
inner_join(stations, by = "Station")Defining a custom color palette for better visuals
pal <- colorNumeric(palette = "viridis", domain = merged_data$Median_Rainfall)Interactive Map and Embedding
The map uses leaflet to display weather stations as circle markers. Stations are color-coded based on their median rainfall levels using a gradient color scale.
This code creates an enhanced interactive map using the leaflet package to visualize median rainfall data by station.
Key features include:
1.A custom map tile for improved aesthetics.
2.Circle markers whose size is proportional to the square root of median rainfall, colored based on rainfall values, and with detailed popups and tooltips displaying station information.
3.A dynamic legend to indicate the rainfall color scale and a scale bar for better map context.
4.The map is centered optimally to show all stations, providing a user-friendly experience for exploration.
# Created an enhanced interactive map
leaflet(data = merged_data) %>%
# Added a custom map tile for better aesthetics
addProviderTiles(providers$CartoDB.Positron) %>%
# Added circle markers with enhanced tooltips
addCircleMarkers(
~Long, ~Lat,
radius = ~sqrt(Median_Rainfall) * 0.5, # Scaled radius based on rainfall
color = ~pal(Median_Rainfall),
popup = ~paste(
"<h4>", Station, "</h4>",
"<b>Median Rainfall:</b> ", Median_Rainfall, " mm<br>",
"<b>Latitude:</b> ", Lat, "<br>",
"<b>Longitude:</b> ", Long
),
label = ~paste(Station, ": ", Median_Rainfall, " mm"), # Tooltip on hover
stroke = TRUE,
weight = 2,
fillOpacity = 0.8
) %>%
# Added a dynamic legend for the rainfall color scale
addLegend(
"bottomright",
pal = pal,
values = ~Median_Rainfall,
title = "Median Rainfall (mm)",
labFormat = labelFormat(suffix = " mm"),
opacity = 1
) %>%
# Added a scale bar for context
addScaleBar(
position = "bottomleft",
options = scaleBarOptions(
metric = TRUE,
imperial = FALSE
)
) %>%
# Centered the map to show all stations optimally
setView(lng = mean(merged_data$Long), lat = mean(merged_data$Lat), zoom = 6)Results and Observations
Discussion
This analysis of Ireland’s median January rainfall over 164 years highlights significant regional variations, with some stations experiencing notably higher rainfall and others considerably lower levels of precipitation.
Regional Variations:
Southern and Southeastern Ireland:
Stations such as Killarney (177.7 mm), Valentia (176 mm), Cappoquinn (147.4 mm) and Cork Airport(134.6 mm) recorded high rainfall. These stations, marked with large yellow to green shaded circles, are located in regions that experience the most precipitation due to their proximity to the Atlantic and coastal weather systems.
The south of Ireland is frequently affected by low-pressure systems and depressions that form over the Atlantic. These systems bring rainfall, especially in the winter months. As these weather systems move across Ireland, they primarily impact the south, bringing consistent and often heavy rain.
Northwestern Ireland:
Ardara (171.6 mm), located in the northwest of Ireland, recorded high rainfall, exceeding 150 mm. This station is marked with a large yellow circle, reflecting the significant precipitation in the region, driven by its exposure to Atlantic weather patterns.
Moderate Rainfall Areas:
Stations such as Rathdrum (126.6 mm), University of Galway (124.1 mm), and Portlaw (123.3 mm) recorded moderate rainfall, marked with medium-sized yellow and purple circles. These stations represent areas experiencing significant rainfall but still below the highest recorded values.
Lower-Rainfall Stations:
Other stations, including those in the northeastern and midland regions, such as Dublin Airport(63 mm) and Phoenix park(67.6 mm), received rainfall below 100 mm. These stations are represented by smaller purple circles, indicating drier conditions typical of inland areas or those shielded by topographical features.
Birr station which is located in the middle part of Ireland received low median rainfall of about 77.5 mm showing that middle regions are safer and with low flood risk.
Influence of Coastal Proximity and Topography:
The southern regions of Ireland, including Cork, Kerry, and Waterford, are coastal and thus more directly influenced by the Atlantic weather systems. Coastal areas receive more rainfall due to their exposure to the ocean, while inland areas are somewhat shielded by topographical features. Additionally, the influence of warm ocean currents (like the Gulf Stream) in the Atlantic also helps maintain relatively mild temperatures, which can further enhance moisture in the atmosphere.
The rainfall differences observed can be attributed to several factors, including coastal proximity, Atlantic weather systems, and Ireland’s topography. Coastal regions, particularly in the southeast and northwest, receive more moisture from the Atlantic, resulting in higher rainfall amounts. Inland or more sheltered areas, particularly in the middle and northeast, experience drier conditions and lower rainfall.
Utility of the Visualization:
The interactive map effectively visualizes these regional differences with large yellow (high rainfall) and small purple (low rainfall) markers. This makes the map an excellent tool for understanding the spatial distribution of rainfall, which can be useful for sectors such as agriculture, water resource management, and urban planning. For example, areas with higher rainfall may require flood management strategies, while drier areas could benefit from water conservation efforts.
Limitations:
The map reflects median rainfall for January only, offering a snapshot of monthly precipitation. Future versions could incorporate dynamic filters to explore rainfall trends across different months or years.
Other factors such as wind patterns, elevation, and proximity to bodies of water, which could influence rainfall distribution, are not considered here but could provide additional insights.
Conclusion:
Overall, the analysis reveals that Killarney receives the highest rainfall in Ireland for January, with a recorded total of 177.7 mm, followed closely by Valentia and Ardara. These stations, located in the southeast and northwest, experience the most precipitation. In contrast, stations in eastern and northeastern regions, such as Dublin Airport recieved the lowest median rainfall of about 63 mm followed by Phoenix park with 67.6 mm due to the rain shadow effect and more sheltered conditions.
The interactive map clearly highlights this regional rainfall distribution, with yellow markers indicating areas of high precipitation and purple markers showing areas with lower rainfall. This visualization offers valuable insights for applications in agriculture, water management, and flood risk assessment, with potential for further exploration of additional factors like elevation and wind patterns to enhance the understanding of rainfall variability.