In this project. a visualisation of monthly rainfall data from four different weather stations in Ireland: Dublin Airport, Cork Airport, Belfast and University College Galway. The purpose of this analysis is to compare the rainfall patterns at these stations over time and provide insights into weather trends at different areas in Ireland. Rainfall plays a vital role in shaping Ireland environment, agriculture and in some cases daily life. Visualisations offer a comparative perspective on rainfall trends, easily highlighting similarities and difference across regions.
The data set used for this project provided by Prof Chris Brunsdon. This data set contains monthly rainfall measurements for each weather station in Ireland, ranging from the 1850s onwards to 2014. The data is from a pre-saved RData file and allows for efficient data handling. Each record includes the Station, Year, Month and amount of rainfall
To prepare the data for visualisation, monthly rainfall totals for each station were extracted and converted into time series objects.
install.packages("tidyverse", repos = "https://cloud.r-project.org/")
## Installing package into 'C:/Users/ellen/AppData/Local/R/win-library/4.4'
## (as 'lib' is unspecified)
## package 'tidyverse' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\ellen\AppData\Local\Temp\Rtmpya5O9y\downloaded_packages
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.4.2
## ── 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
install.packages("sp", repos = "https://cloud.r-project.org/")
## Installing package into 'C:/Users/ellen/AppData/Local/R/win-library/4.4'
## (as 'lib' is unspecified)
## package 'sp' successfully unpacked and MD5 sums checked
## Warning: cannot remove prior installation of package 'sp'
## Warning in file.copy(savedcopy, lib, recursive = TRUE): problem copying
## C:\Users\ellen\AppData\Local\R\win-library\4.4\00LOCK\sp\libs\x64\sp.dll to
## C:\Users\ellen\AppData\Local\R\win-library\4.4\sp\libs\x64\sp.dll: Permission
## denied
## Warning: restored 'sp'
##
## The downloaded binary packages are in
## C:\Users\ellen\AppData\Local\Temp\Rtmpya5O9y\downloaded_packages
library(sp)
## Warning: package 'sp' was built under R version 4.4.2
install.packages("dygraphs", repos = "https://cloud.r-project.org/")
## Installing package into 'C:/Users/ellen/AppData/Local/R/win-library/4.4'
## (as 'lib' is unspecified)
## package 'dygraphs' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\ellen\AppData\Local\Temp\Rtmpya5O9y\downloaded_packages
library(dygraphs)
## Warning: package 'dygraphs' was built under R version 4.4.2
install.packages("RColorBrewer", repos = "https://cloud.r-project.org/")
## Installing package into 'C:/Users/ellen/AppData/Local/R/win-library/4.4'
## (as 'lib' is unspecified)
## package 'RColorBrewer' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\ellen\AppData\Local\Temp\Rtmpya5O9y\downloaded_packages
library(RColorBrewer)
install.packages("rmarkdown", repos = "https://cloud.r-project.org/")
## Installing package into 'C:/Users/ellen/AppData/Local/R/win-library/4.4'
## (as 'lib' is unspecified)
## package 'rmarkdown' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\ellen\AppData\Local\Temp\Rtmpya5O9y\downloaded_packages
library(rmarkdown)
## Warning: package 'rmarkdown' was built under R version 4.4.2
##the packages needed for this project
##str(rainfall)
##shows the all the data
The filter() function ,from the dplyr package, is used to select rows from a dataset based on specified conditions, Stations == “Dublin Airport”. Combined with the functions like summarise(), group_by() allows for clean, data processing. this ensures that each stations data is neatly extracted.
The Start = c() function means that the time series is set to start in the year 1850. The freq =12 means that the monthly data could be taken as there is 12 months in a year
The pull() function extracts the rainfall data as a number.
The ts() function in R was used to endure that the data maintained the chronological order with the starting point and frequency of the data contained. This allowed for a time-based analysis and visualisation.
## Load the rainfall data
load("rainfall.RData")
## the time series for each airport
# Dublin
rain %>% filter(Station=="Dublin Airport") %>% summarise(Rainfall=sum(Rainfall),.by=c(Year,Month)) %>% pull(Rainfall) %>% ts(start=c(1850,1),freq=12) -> dubairport_ts
#Belfast
rain %>% filter(Station=="Belfast") %>% summarise(Rainfall=sum(Rainfall),.by=c(Year,Month)) %>% pull(Rainfall) %>% ts(start=c(1850,1),freq=12) -> belfast_ts
#Galway
rain %>% filter(Station=="University College Galway") %>% summarise(Rainfall=sum(Rainfall),.by=c(Year,Month)) %>% pull(Rainfall) %>% ts(start=c(1850,1),freq=12) -> UCGalway_ts
#Cork
rain %>% filter(Station=="Cork Airport") %>% summarise(Rainfall=sum(Rainfall),.by=c(Year,Month)) %>% pull(Rainfall) %>% ts(start=c(1850,1),freq=12) -> corkAirport_ts
There are key functions to ensure the weather stations are combined and displayed properly.
The cbind() function was used to combine the time series data for each of the four weather stations. This allows for the stations to be displayed in the figure below.
To project this figure the dyGraph() function from he dygraphs package is used to create an interactive time series plot. this allows for the interactive legend.
The dyAxis function is used to add headings to the axes to better communicate the data in the graph.
dySeries() allows to the colour display of the data. Each station is represented as a seperate series on the plot and is assigned different colours to make them visually distinctive.
Finally the rangeSelector() function adds a range selector to the graph, allowing for the selecting of a specific range
This graph allows the users to compare the rainfall patterns of four different weather stations in Ireland over time. The interactive nature of the dygraph allows for specific ranges to be set and inspected.
##combine all 4 stations data into the one data set
all4Stations_ts <- cbind(corkAirport_ts, dubairport_ts, belfast_ts, UCGalway_ts)
##find the min and maximum values of rainfall so that the proper height can be set
max(all4Stations_ts)
## [1] 460.5
min(all4Stations_ts)
## [1] 0.4
all4Stations_ts %>% dygraph(width=1000, height=480) %>% dyRangeSelector()
##making headings for the legend
##Add in heading for the graph
dygraph(all4Stations_ts, main = "Monthly Rainfall at 4 Weather Stations", width=1000, height=480) %>% dyAxis("y", label = "Rainfall(mm)") %>% dyAxis("x", label = "Date")%>% dySeries("corkAirport_ts", color = "blue")%>% dySeries("dubairport_ts", color= "orange")%>% dySeries("belfast_ts", color = "green")%>% dySeries("UCGalway_ts", color= "brown") %>% dyRangeSelector()
##change the colour of each stations line from the default colours
The same functions were used to create the individual graphs but the range() function was introduced to set each of the graphs to a certain y range. this function calculates the minimum and maximum values for the specific station. Setting the y-axis range to the station with the highest rainfall value means the scale remains consistent for all the graphs. This allows for an easy comparison of trends, as the highest rainfall value will be visible on each graph.
##individual
# cork airport individual graph with the y range set to the maximum number in range of the stations
cork_range <- range(corkAirport_ts, na.rm = TRUE)
dygraph(corkAirport_ts, main= "Monthly Rainfall at Cork Airport", width=1000, height=480) %>% dyAxis("y", label = "Rainfall (mm)", valueRange = cork_range) %>%dyAxis("x", label = "Date")%>% dySeries(color = "blue")%>% dyRangeSelector()
# range for y set to the range from the cork station because it holds the largest values from all 4 stations
dygraph(dubairport_ts, main= "Monthly Rainfall at Dublin Airport", width=1000, height=480) %>% dyAxis("y", label = "Rainfall (mm)", valueRange = cork_range) %>%dyAxis("x", label = "Date")%>% dySeries(color= "orange") %>% dyRangeSelector()
#Belfast
dygraph(belfast_ts, main= "Monthly Rainfall Belfast", width=1000, height=480) %>% dyAxis("y", label = "Rainfall (mm)", valueRange = cork_range) %>%dyAxis("x", label = "Date")%>% dySeries(color = "green") %>% dyRangeSelector()
#Galway
dygraph(UCGalway_ts, main= "Monthly Rainfall at University College Galway", width=1000, height=480) %>% dyAxis("y", label = "Rainfall (mm)", valueRange = cork_range) %>%dyAxis("x", label = "Date")%>% dySeries( color= "brown") %>% dyRangeSelector()
The individual and combined time series graphs of monthly rainfall at four weather stations provide valuable insights into the rainfall patterns across four different regions of Ireland.
From the combined graph, we can see the rainfall patterns at each station show similar seasonal fluctuations, with a decrease in rainfall at summer and increase in winter. This seasonal variation is common in climates such as Ireland, where the influence of oceanic weather systems leads to wetter conditions during the colder months.
There are also differences in the amounts of rainfall across the stations. Cork Airport has the highest record of rainfall compared to the over stations. This could be due to Corks location on the south-west of Ireland. This means Cork is more exposed to moist air from the Atlantic Ocean. The graph backs up the claim that the southwest experiences higher rainfall than the other parts of Ireland.
From Corks individual graph, it experiences an increase in rainfall during the winter months.
Dublin Airports graph,displays a more moderate rainfall pattern, With increases and decrease occurring at different times of the year. Located in the east of Ireland there tends to be lower amounts of rainfall due to being less exposed to the Atlantic Ocean, resulting in less frequent and intense amounts of rainfall.
Belfast, similar to Dublin Airport experiences high levels of rainfall in Winter and lower in Summer months. The level of rainfall tends to be higher than Dublin due to its location in relation to the north channel, which could influence rainfall.
In Galway, the patterns are similar to Cork, but with lower levels of rainfall. Galway is located on the west coast where, like Cork, the Atlantic Ocean could have influence in the levels of rainfall. Its exposure to these conditions are less than Corks and therefore means a lower amount of rainfall overall.
The ability to zoom in and examine the different time periods using the function, dyRangeSelector is useful for identifying these patterns.
in conclusions the visualisations of the time series offer a clear view of the rainfall patterns at four weather stations across Ireland. The stations share similar seasonal trends, these are regional differences in the amount of rainfall, with Cork Airport consistently having higher values. The use of the range() function helps to normalise the data, allowing for easier comparison between stations and highlighting rainfall events. Overall, these graph give insights into Ireland’s climate, showing the effects of location on rainfall patterns and ehlping to better understand regional rainfall.