Monthly rainfall data from selected weather stations in Ireland are analyzed, to reveal patterns in the country’s climatic trends. The rainfall trend is explored and interpreted with the help of various visualisation techniques, on stations in Belfast, Dublin Airport, University College Galway and Cork Airport. Using tools including R’s dygraphs, ggplot2, tmap, This analysis produce interactive as well as static renderings of the data that aid in a better appreciation for seasonal variations; station comparisons; and rainfall distributions. In addition to providing vital visualizations of the differences in rainfall amounts between locations, these visualizations bring to light patterns that might serve as clues for future climatic studies and environmental management strategies. It provides the necessary background for a thorough analyzed of visualizations as well as patterns in the generated data.
library(tidyverse)
library(xts)
library(dygraphs)
library(tmap)
library(sf)
load("C:/Users/crick/Downloads/Rpubs/rainfall.Rdata")
The dataset utilized for this analysis consists of monthly rainfall measurements collected from five specific weather stations in Ireland: University College Galway and Belfast and Cork Airport. Data is available over a broad range of years to which This analysis can explore rainfall patterns over time. Each record includes the station name, year, month, and the total rainfall recorded in millimetres. The structure of the dataset is as follows: * Station: A location such as the name of weather station. * Year: The recorded year of the rain. * Month: The date that the recorded rainfall happened. * Rainfall: Amount of rainfall in millimetres.
With this structured format, it is easy to manipulate, wrap and visualize the data, using packages like dplyr for wrangling and dygraphs for interactive visualization, within R
selected_stations <- c("Belfast", "Dublin Airport", "University College Galway", "Cork Airport")
# Filter and reshape the data for the selected stations
rainfall_filtered <- rain %>%
filter(Station %in% selected_stations) %>%
mutate(
# Combine Year and Month into a Date
date = as.Date(paste(Year, Month, "01", sep = "-"), format = "%Y-%b-%d"),
month = format(date, "%Y-%m") # Extract Year-Month for grouping
) %>%
group_by(date, Station) %>% # Group by Date and Station
summarise(total_rainfall = sum(Rainfall, na.rm = TRUE), .groups = "drop") %>% # Summarize rainfall
pivot_wider(names_from = Station, values_from = total_rainfall) # Reshape for time series
# Convert the data to xts format (required by dygraphs)
rainfall_xts <- xts(rainfall_filtered %>% select(-date), order.by = rainfall_filtered$date)
For visualization of the monthly rainfall data, this analysis uses the dygraphs package in R. This package allows for the creation of dynamic time-series graphs that provide interactive capabilities, such as zooming into specific time frames via a RangeSelector control. The process involves several key steps:
This analysis when has been done have the interactive graph can then publish it on RPubs, which is a platform that lets share R Markdown documents. In this step This analysis embeds the dygraph within an R markdown file containing explanations and analyses of the data
The analysis presents six distinct visualizations that collectively illustrate the monthly rainfall data from four selected weather stations in Ireland: University College Galway, Belfast, Dublin Airport, Cork Airport. Each of these visualizations helps to uncover rainfall patterns and distributions in and around these locations. Each visualization below is discussed briefly and the identified patterns are presented.
dygraph(rainfall_xts, main = "Monthly Rainfall for Selected Stations") %>%
dyRangeSelector() %>% # Add range selector
dyAxis("y", label = "Rainfall (mm)") %>%
dyOptions(colors = RColorBrewer::brewer.pal(4, "Set1"))
The first one is a dygraphs (R) package based interactive time series graph. This graph displays the monthly rainfall for the selected weather stations over time. Patterns Observed: • Seasonal Trends: It shows clear seasonal patterns: increased rainfall during October to March and less rainfall during June to August. • Station Comparisons: Rainfall totals tend to be higher generally in Belfast and in winter than the other stations, although in Dublin Airport rainfall is more consistent with a drier summer. • Anomalous Events: Rainfall spikes in some months suggest extreme weather events that may deserve more attention.
ggplot(rain %>% filter(Station %in% selected_stations), aes(x = Station, y = Rainfall, fill = Station)) +
geom_boxplot() +
labs(title = "Boxplot of Rainfall by Station", x = "Station", y = "Rainfall (mm)") +
theme_minimal() +
theme(legend.position = "none")
The second visualization is a boxplot that compares the distribution of
rainfall across the four weather stations. Patterns Observed: •
Variability in Rainfall: Rainfall amounts recorded at different stations
are significantly variable as can be seen on the boxplot. The monthly
rainfall for the two is relatively similar in terms of the mean and has
a more identical shape in terms of the interquartile range, meaning the
other indicators of variability. • Outliers: All stations exhibited
several outlier points in which there are occasional extreme rainfall
events that happen outside of the typical monthly totals
###An interactive map visualizes the geographical locations of the selected weather stations. Patterns Observed: • Geographical Distribution: The map gives context to how geographical factors may control how rainfall happens in different regions in Ireland. • Station Accessibility: Graphic representation of the stations on a map makes it easier to assess closeness between stations and explain candidacy of more climatic influences because of their locations Density plot: Rainfall distribution for all stations
ggplot(rain, aes(x = Rainfall, fill = Station)) +
geom_density(alpha = 0.4) +
labs(title = "Density Plot of Rainfall for All Stations", x = "Rainfall (mm)", y = "Density") +
theme_minimal()
This visualization presents a density plot illustrating the distribution
of rainfall across all selected stations. Patterns Observed: •
Distribution Shape: The density plot shows that most of the rainfall
measurements fall close to lower values and decrease gradually as values
increase. Heavy rains are less frequent, suggesting that rain however
heavy, does not occur that often. • Station Differences: The density
curves at each station are different and in Belfast the curve is broader
than the others, indicating greater variability in rainfall amounts
station_coords <- stations %>%
filter(Station %in% selected_stations) %>%
select(Station, Lat, Long)
# Convert the filtered data to a spatial object
station_sf <- st_as_sf(station_coords, coords = c("Long", "Lat"), crs = 4326)
# Interactive map of stations
tmap_mode("view")
tm_shape(station_sf) +
tm_dots("Station", size = 0.2, col = "blue", title = "Weather Stations") +
tm_basemap("OpenStreetMap")
An interactive map visualizes the geographical locations of the selected weather stations. Patterns Observed: • Geographical Distribution: The map gives context to how geographical factors may control how rainfall happens in different regions in Ireland. • Station Accessibility: Graphic representation of the stations on a map makes it easier to assess closeness between stations and explain candidacy of more climatic influences because of their locations
ggplot(rain, aes(x = Month, y = Rainfall, fill = Month)) +
geom_boxplot() +
labs(title = "Boxplot of Monthly Rainfall Across Stations", x = "Month", y = "Rainfall (mm)") +
theme_minimal() +
theme(legend.position = "none")
This boxplot focuses on the distribution of monthly rainfall across all
selected stations for each month of the year. Patterns Observed: •
Monthly Variability: Furthermore, the boxplot shows the huge variation
in monthly rainfall in time. Median values are higher in winter months
than in summer months. • Comparative Analysis: This provides direct
comparability of how the monthly averages vary between each station and
interesting peaks across all stations
mean_rain_data <- rain %>%
filter(Station %in% selected_stations) %>%
group_by(Station) %>%
summarize(mean_rain = mean(Rainfall, na.rm = TRUE))
station_data <- stations %>%
filter(Station %in% selected_stations) %>%
select(Station, Lat, Long) %>%
inner_join(mean_rain_data, by = "Station")
# Convert the data to a spatial object
station_sf <- st_as_sf(station_data, coords = c("Long", "Lat"), crs = 4326)
# Create the choropleth map
tmap_mode("view")
tm_shape(station_sf) +
tm_bubbles(size = "mean_rain", col = "mean_rain",
title.size = "Mean Rainfall (mm)",
title.col = "Mean Rainfall (mm)",
palette = "Blues", style = "pretty") +
tm_basemap("OpenStreetMap")
The final visualization is a choropleth map that displays mean rainfall for each station. Patterns Observed: • Mean Rainfall Variability: The choropleth emphasizes the differences in the mean rain, with Belfast station again showing a higher value than the Cork Airport station. • Visual Impact: In fact, the use of colour gradients gives the visual impression of differences in mean rainfall, allowing us to quickly determine the areas which typically have received more precipitation
Upon examining the interactive dygraph, several notable patterns emerge regarding monthly rainfall across the selected weather stations: • Seasonal Variability: The graph clearly shows seasonal variations of rainfall distribution. Late autumn and winter months that is usually observed are the times of higher rainfall (November to February), while summer months that is sometimes observed is characterized of low precipitation (June to August). As climatic expectations align with this trend, this is also expected for Ireland and its wet winters. • Comparative Analysis Among Stations: The stations vary according to their own rainfall characteristics. • Accordingly, during winter months Belfast usually records higher total monthly rainfall than other locations. • Rainfall at Dublin Airport shows steady levels throughout the year but fluctuation slightly during autumn. • Sporadics in the rainfall variability of University College Galway are demonstrated, with sporadic spikes in rainfall during some months. • Although overall rainfall at Cork Airport is less than at Belfast, the same seasonality applies. • Anomalies and Extreme Events: The graph also shows periods of excessive weather when monthly totals of rainfall are exceptional. They may be related to certain climatic events or changes in the weather pattern over Ireland. • Long-term Trends: In several years, the pattern in monthly rainfall may well begin to change, and hence may indicate an effect of climate change, or of other environmental factors. Further statistical analysis beyond simple visualization is needed to analyse these long term trends.
Using R’s dygraphs package, a powerful interactive dygraph is created to visualize and analyse monthly rainfall data at selected weather stations in Ireland. But our ability to engage with the data improves once This analysis incorporates features like a RangeSelector control so that users are able to search specific time frames and compare patterns over different locations, which helps us to better understand regional climatic conditions as well as lay a groundwork for understanding how these patterns may change as broader climatic conditions shift. This conjoining of graphical representation with the analysis of observed trends highlights the significance of good data visualization in climatological studies.
R Core Team, 2023. R: A language and environment for statistical computing. Vienna: R Foundation for Statistical Computing. Available at: https://www.R-project.org [Accessed 28 Dec. 2024]. Wickham, H., 2023. tidyverse: Easily install and load the ‘tidyverse’. R package version 2.0.0. Available at: https://CRAN.R-project.org/package=tidyverse [Accessed 28 Dec. 2024]. Xie, Y., 2023. knitr: A general-purpose package for dynamic report generation in R. R package version 1.43. Available at: https://yihui.org/knitr/ [Accessed 28 Dec. 2024]. Dunnington, D., 2022. dygraphs: An R package for interactive time series visualizations. R package version 1.1.7. Available at: https://cran.r-project.org/web/packages/dygraphs/index.html [Accessed 28 Dec. 2024].