This blog explores the median rainfall levels in January for 25 weather stations across Ireland, spanning the years 1850–2014. Using advanced spatial data visualization techniques, we have created an interactive map that enables the observation of these variations and uncover potential patterns and causes.
This report provides a detailed explanation of the data, the R code used to process and visualize it, and a discussion of the resulting map. By the end, we aim to understand the spatial distribution of rainfall in Ireland and its implications for weather analysis.
The dataset contains rainfall measurements from 25 weather stations in Ireland, specifically for the month of January. It includes columns such as the Rainfall, Station, Month, geographic coordinates (Easting and Northing), and other metadata like Elevation and County. The dataset consists of 49,500 rows, spanning multiple years of observations. The analysis aggregates the median rainfall for January at each station to visualize spatial patterns.
The following R libraries are essential for data manipulation and spatial visualization:
tidyverse and dplyr : For data manipulation and analysis, These libraries facilitate efficient data wrangling, filtering, grouping, and summarization.
sf (Simple Features) : This library is crucial for handling geospatial data. Functions like st_read() and st_join() helps to read and perform spatial joins.
tmap : A powerful library for creating both static and interactive maps, with functions like tm_shape(), tm_dots() etc, it helps us to define and visualize the spatial data.
leaflet : This library enhances interactivity by converting static maps into dynamic web-based maps.
RColorBrewer : This provides visually appealing color palettes for maps.
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats 1.0.0 ✔ readr 2.1.5
## ✔ ggplot2 3.5.1 ✔ stringr 1.5.1
## ✔ lubridate 1.9.3 ✔ tibble 3.2.1
## ✔ purrr 1.0.2 ✔ tidyr 1.3.1
## ── 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(tmap)
## Breaking News: tmap 3.x is retiring. Please test v4, e.g. with
## remotes::install_github('r-tmap/tmap')
library(sf)
## Linking to GEOS 3.12.2, GDAL 3.9.3, PROJ 9.4.1; sf_use_s2() is TRUE
library(RColorBrewer)
library(sp)
library(leaflet)
Step 1: Reading the GeoJSON File
GeojsonData <- st_read("C:/Users/imaka/Downloads/weather_stations.geojson", quiet = TRUE)
The st_read() function loads the gj object from a GeoJSON file containing spatial and rainfall data. The dataset is stored as a sf object, enabling geospatial operations.
Step 2: Filtering January Data and Computing Median Rainfall
station_median <- GeojsonData %>%
filter(Month == "Jan") %>%
group_by(Station) %>%
summarize(
median_rainfall = median(Rainfall, na.rm = TRUE),
geometry = st_union(geometry) # Ensures geometry is retained for each station
) %>%
ungroup()
Here, we’re extracting data from January using ‘filter(Month == “Jan”)’ on the gj object and grouping the data by weather stations with ‘group_by(station)’. Next, we calculate the median rainfall for each station, ignoring missing values, and finally, we aggregate the spatial geometries of each station using ‘st_union(geometry)’.
Step 3: Creating the Map
tmap_mode("view")
tm_start <- tm_shape(station_median) +
tm_dots(
col = "median_rainfall",
palette = "-RdYlBu",
size = 0.15,
popup.vars = c("Station" = "Station", "Median Rainfall" = "median_rainfall"),
title = "Median Rainfall (mm)"
) +
tm_layout(
title = "Median Rainfall in January (Ireland)",
legend.outside = TRUE
)
Step 3 involves creating a map to visualize median rainfall in Ireland. The code uses tm_shape() to define the spatial dataset and tm_dots() to display stations as dots, colored by rainfall levels. Interactive pop-ups, created with popup.vars, show station names and rainfall data. Finally, tm_layout() customizes the map’s title and the placement of the legend.
Step 4: Adding Interactivity
interactive_map <- tmap_leaflet(tm_start) %>%
addTiles() %>%
addScaleBar(position = "bottomleft") %>%
addMiniMap(zoomLevelOffset = -3, toggleDisplay = TRUE)
The tmap_leaflet() function converts a static map into an interactive leaflet map. Additional tools, such as a scale bar and mini-map, are added using addScaleBar() and addMiniMap(). Moreover with function addTiles() we can select the base map like OpenStreetMap layer.
GeojsonData <- st_read("C:/Users/imaka/Downloads/weather_stations.geojson", quiet = TRUE)
# Filter January data and compute median rainfall directly
station_median <- GeojsonData %>%
filter(Month == "Jan") %>%
group_by(Station) %>%
summarize(
median_rainfall = median(Rainfall, na.rm = TRUE),
geometry = st_union(geometry) # Ensure geometry is retained for each station
) %>%
ungroup()
# Create the map
tmap_mode("view")
## tmap mode set to interactive viewing
tm_start <- tm_shape(station_median) +
tm_dots(
col = "median_rainfall",
palette = "-RdYlBu", # Red to Blue color scheme for rainfall
size = 0.15,
popup.vars = c("Station" = "Station", "Median Rainfall" = "median_rainfall"), # Custom popup labels
title = "Median Rainfall (mm)"
) +
tm_layout(
title = "Median Rainfall in January (Ireland)",
legend.outside = TRUE
)
# Convert to interactive leaflet map
interactive_map <- tmap_leaflet(tm_start) %>%
addTiles() %>%
addScaleBar(position = "bottomleft") %>%
addMiniMap(zoomLevelOffset = -3, toggleDisplay = TRUE)
# View the map
interactive_map
The interactive map effectively visualizes the spatial distribution of median rainfall levels across Ireland during the month of January. By using a red-to-blue gradient for color-coding, the map offers an intuitive representation of rainfall intensity, making it easy to identify regions with higher and lower rainfall.
Red : Represents the highest rainfall levels (approximately 160–180 mm), signifying regions with substantial precipitation.
Blue : Indicates the lowest rainfall levels (around 60–80 mm), showing areas with relatively dry conditions.
The map’s interactivity enhances user engagement, allowing users to hover over or click on stations to view detailed information about median rainfall and station names. This feature provides an excellent tool for exploring localized rainfall patterns.
High Rainfall in the Southwest
The southwest region of Ireland emerges as the area with the most significant rainfall levels, as evidenced by stations like:
Killarney (~177.7 mm)
Valentia (~166 mm)
These stations, highlighted in red on the map, experience some of the highest rainfall levels in January. This phenomenon can be attributed to a combination of geographical and climatic factors:
Proximity to the Atlantic Ocean:- The southwest faces the prevailing westerly winds that carry moisture from the Atlantic, resulting in frequent and intense rainfall.
Orographic Effect:- The moist Atlantic air is forced to rise over mountainous terrain, such as the MacGillycuddy’s Reeks in County Kerry. As the air rises, it cools and condenses, leading to increased precipitation in these regions.
This pattern aligns with Ireland’s climatic characteristics, where western coastal areas generally receive more rainfall due to their exposure to oceanic influences.
Lower Rainfall in the East
The eastern and midland regions of Ireland, including stations like:
Dublin Airport (~63 mm)
Phoenix Park (~67.6 mm)
Birr (~77.5 mm)
are shown in shades of blue on the map, reflecting their significantly lower median rainfall levels (60–80 mm). This disparity is primarily due to:
Rain-Shadow Effect:- Mountains in the west and southwest act as barriers, blocking moist air from reaching the east. As a result, the eastern regions receive less precipitation, leading to drier conditions.
Distance from the Atlantic:- Eastern areas are further removed from the moisture-laden winds of the Atlantic, reducing the likelihood of heavy rainfall.
While the east receives less rainfall compared to the west, its relatively dry conditions are beneficial for urban infrastructure and certain agricultural activities, which thrive under moderate rainfall levels.
Additionally stations like Rathdrum, Waterford, Cork Airport etc. in the South East show the average median rainfall varied from 100 to 140 with sufficient rains recorded and helpful for the agriculture and water resource.
Regional Disparities
The map vividly illustrates a gradient of rainfall from west to east:
Western Ireland: Experiences high rainfall due to direct exposure to Atlantic weather systems.
Eastern Ireland: Markedly drier due to its sheltered position behind the mountains.
This west-to-east rainfall gradient is a prominent feature of Ireland’s climate and is shaped by the interplay of geography and prevailing weather patterns.
Coastal Influence
Coastal areas across the country tend to receive higher rainfall due to their proximity to the sea, which provides a continuous source of moisture. For example:
Southwestern Coastal Stations:- Such as those in Kerry and Cork, exhibit high rainfall levels.
Eastern Coastal Stations:- Like Waterford, also receive moderate rainfall (~100–140 mm), although less than their western counterparts.
Impact of Inland Terrain
Inland regions, particularly in the midlands, experience less rainfall due to their distance from the Atlantic and the shielding effect of surrounding terrains. Stations like Birr (~77.5 mm) and Mullingar (~80.6mm) reflect this pattern, with moderate rainfall levels that are lower than coastal areas.
Ireland’s rainfall distribution is shaped by its geographic location, climatic systems, and topography. Key influencing factors include:
Atlantic Ocean and Westerlies
Moist westerly winds from the North Atlantic bring significant precipitation, especially in winter months like January.
Orographic Uplift
Mountain ranges, such as the MacGillycuddy’s Reeks and Wicklow Mountains, force moist air to rise and condense, leading to heavy rainfall on the windward side.
Rain-Shadow Effect
As air descends on the leeward side of mountains, it loses moisture, resulting in drier conditions in areas like Dublin.
Elevation
Higher elevations receive more rainfall due to orographic effects, while lower regions, such as the midlands, are drier.
Seasonal Variations
Increased rainfall in winter, driven by frequent Atlantic depressions, results in wetter conditions, particularly in January.
This analysis highlights regional disparities in Ireland’s January rainfall, shaped by geographic, climatic, and topographic factors. The west and southwest experience higher rainfall due to the Atlantic’s influence and orographic uplift, while the east is drier due to the rain-shadow effect. Coastal areas, particularly in the west, receive more rain, while inland regions are drier.
Understanding these patterns is crucial for water resource management, agriculture, and climate research. Future studies could examine temporal trends, elevation’s role, and climate change impacts. This knowledge is vital for informed decisions in flood prevention, resource allocation, and sustainable urban development, ensuring resilience in managing Ireland’s water resources amid a changing climate.