Introduction

This blog will analyse rainfall data for 25 weather stations in Ireland. The median rainfall data will be calculated for each weather station for the month of January using rainfall data from 1850 to 2014. The median value is used as the summary statistics as it will deal with any outliers in the data. The median rainfall levels will be mapped for each station which will be colour coded to represent rainfall levels. The final map will visualise the median rainfall levels for Ireland.

Background Research

A similar study carried out by Mateus and Coonan (2023) investigated median rainfall for the Republic of Ireland for three different return periods. The median rainfall levels ranged from 40mm to 260mm for these periods. The maps showed the highest level of rainfall along the west coast and the lowest levels were recorded in the midlands and along the east coast. Using a long period of data allows for the climate to be analysed (Mateus & Coonan, 2023).

Data

The two datasets used for this blog are rainfall.RData and weather_stations.geojson. The rainfall data set contains monthly rainfall data for 25 weather stations in Ireland. The rainfall dataset contains the year, the month, the amount of rainfall and the name of the weather station where the data was collected from. The weather stations data file type is a GeoJSON which stores the locations of the weather station and their non-spatial attributes. The weather stations dataset contains the name of each station, its elevation, its easting, its northing, its longitude, its latitude, its county, its abbreviation and its source.

The median of the rainfall data was found instead of the mean as it will deal with outliers in the data. For example, a median rainfall of 0 was recorded for the Valentia weather station in January 1934. Valentia has one of the highest median rainfall levels for January. This suggests that the 0 value is an outlier caused by an incorrect reading at the weather station. There are likely many more incorrect readings in the rainfall data.

The Code

Setting the Working Directory and Loading the Data

The data for the project needs to be added to the same folder. The working directory needs to be set to this folder, and the rainfall data is loaded in using the load function. Rain and stations show the contents of both datasets.

setwd("~/Downloads/GY672 Assignment 2")
load('rainfall.RData')

#rain
#stations

Installing the R packages

Some codes need certain packages installed to allow them to run. The dplyr package was installed and then loaded using the library function. The dplyr package is needed for the group by, pipeline and filter functions. The pipe operation allows the first step to be piped into the second step. The leaflet package is installed for the interactive maps to be created. The tmap library is needed to create thematic maps. The sf package is needed to work with spatial data like the counties. Mapview was called in to allow for the interactive maps to be viewed. Leafpop is used for embedding graphics in interactive maps.

install.packages("dplyr", repos = "https://cloud.r-project.org/") 
## 
## The downloaded binary packages are in
##  /var/folders/xc/13tprn4571g8dzrc9plw5h_w0000gn/T//RtmptMX7PO/downloaded_packages
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
install.packages("leaflet", repos = "https://cloud.r-project.org/") 
## 
## The downloaded binary packages are in
##  /var/folders/xc/13tprn4571g8dzrc9plw5h_w0000gn/T//RtmptMX7PO/downloaded_packages
library(leaflet) 
install.packages("tmap", repos = "https://cloud.r-project.org/") 
## 
## The downloaded binary packages are in
##  /var/folders/xc/13tprn4571g8dzrc9plw5h_w0000gn/T//RtmptMX7PO/downloaded_packages
library(tmap) 
## Breaking News: tmap 3.x is retiring. Please test v4, e.g. with
## remotes::install_github('r-tmap/tmap')
install.packages("sf", repos = "https://cloud.r-project.org/") 
## 
## The downloaded binary packages are in
##  /var/folders/xc/13tprn4571g8dzrc9plw5h_w0000gn/T//RtmptMX7PO/downloaded_packages
library(sf) 
## Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
library(mapview) 
library(leafpop)

Group by Month

The rain data is called in and is getting grouped by the month variable. This allows for the month of January to be extracted from the data. The filter function is used to extract the month of January. The data for that month is then named stations_jan using ->.

rain %>% group_by(Month) %>%
  filter(Month=='Jan') -> stations_jan

Extracting Filename and Station

A new variable called filename is added to the station’s data. The filename has the username, the file name and the station name in it. The station names and filenames are taken from the data using the select function.

stations %>% mutate(Filename=file.path(getwd(),paste0(Station,'.png'))) -> files 
files %>% select(Station,Filename) 
## # A tibble: 25 × 2
##    Station                   Filename                                           
##    <chr>                     <chr>                                              
##  1 Athboy                    /Users/michellegorman/Downloads/GY672 Assignment 2…
##  2 Foulksmills               /Users/michellegorman/Downloads/GY672 Assignment 2…
##  3 Mullingar                 /Users/michellegorman/Downloads/GY672 Assignment 2…
##  4 Portlaw                   /Users/michellegorman/Downloads/GY672 Assignment 2…
##  5 Rathdrum                  /Users/michellegorman/Downloads/GY672 Assignment 2…
##  6 Strokestown               /Users/michellegorman/Downloads/GY672 Assignment 2…
##  7 University College Galway /Users/michellegorman/Downloads/GY672 Assignment 2…
##  8 Drumsna                   /Users/michellegorman/Downloads/GY672 Assignment 2…
##  9 Ardara                    /Users/michellegorman/Downloads/GY672 Assignment 2…
## 10 Armagh                    /Users/michellegorman/Downloads/GY672 Assignment 2…
## # ℹ 15 more rows

Calculating the Median Rainfall Levels and Adding a Coordinate System

The data for January that was filtered out earlier is called in and is grouped by station. The median rainfall value was calculated for each station. The station names, median rainfall levels, filenames and coordinates were calculated for each station. A coordinate system was also added to the data and it was called stations_median.

stations_jan %>% group_by(Station) %>%
  summarise(mrain=median(Rainfall)) %>% left_join(files) %>%
  select(Station,Long,Lat,mrain,Filename) %>%
  st_as_sf(coords=c('Long','Lat'),crs=4326) -> stations_median 
## Joining with `by = join_by(Station)`

Creating the Map

The map is started in tmap and then finished in leaflet. The map created has circular symbols that represent the median rainfall levels using colour. The scale bar was then added to show scale on the image when zooming in and out. The grey colour scale was used as it makes the colours for each station more prominent.

tm_start2 <- tm_shape(stations_median) +  tm_dots(col='mrain',popup.vars=FALSE,scale=1.5)
tmap_leaflet(tm_start2) %>%  
  addCircleMarkers(data=stations_median,stroke = NA,popup=popupImage(stations_median$Filename,embed=TRUE)) %>%
  addScaleBar()

Annual Median Rainfall Levels

The annual median rainfall levels were also found to compare with the January median rainfall levels.

rain %>% group_by(Station) %>%
  summarise(mrain=median(Rainfall))
## # A tibble: 25 × 2
##    Station        mrain
##    <chr>          <dbl>
##  1 Ardara         132. 
##  2 Armagh          65.4
##  3 Athboy          70.7
##  4 Belfast         82.1
##  5 Birr            66.2
##  6 Cappoquinn     113. 
##  7 Cork Airport    90  
##  8 Derry           80.5
##  9 Drumsna         80.2
## 10 Dublin Airport  56  
## # ℹ 15 more rows

Results

The yellow circles show weather stations with the lowest median rainfall levels whereas the dark orange circles show the stations with the highest median rainfall levels. As the colour darkens, the median rainfall levels increase. Hovering over the station shows the station name.

There are large variations evident between inland stations such as Mullingar and coastal stations such as Valentia. Rainfall in Ireland is majorly affected by the Atlantic Ocean. Ireland’s prevailing wind is south westerly meaning the precipitation comes from the Atlantic Ocean. Stations located on the west coast received the highest levels of median rainfall due to the direct impacts of the Atlantic Ocean. The midlands had a lower median rainfall level than the west. The lowest median rainfall levels were recorded in the east of the country and in Birr, Co. Offaly. The patterns identified in this blog are similar to Mateus and Coonan’s (2023) study.

There is variation between coastal stations. Ardara had a median rainfall of 171.6mm whereas Malin Head had a median rainfall of 106.9mm. These stations were expected to have similar values due to their proximity to one another and their proximity to the Atlantic Ocean. The rainfall levels are affected by the weather stations lying between the Inishowen and Derryveagh Mountains and Ireland’s prevailing wind. Ardara is situated on the windward side of the mountains and is exposed to more rainfall whereas Malin Head is sheltered by the mountain ranges. Derry is also on the leeward side of the Derryveagh Mountains, explaining its lower median rainfall level.

Dublin Airport and the Phoenix Park weather stations recorded the lowest levels of median rainfall. These stations are both sheltered by the Wicklow Mountains. The southeast of the country had average rainfall levels. This is likely due to the prevailing wind and the weather stations being located close to the coast.

The difference in elevation also plays a role in median rainfall levels. For example, the Belfast weather station recorded a median rainfall value of 102.1mm and the Armagh weather station recorded a value of 75mm. The Belfast weather station has an elevation of 115m, and the Armagh weather station has an elevation of 62m. This suggests that areas with higher elevation have higher rainfall levels than areas of lower elevations.

Comparison of the January and Annual Median Rainfall Levels

The median annual rainfall levels were calculated for 1850-2014 to compare with the January median rainfall levels. The January median rainfall levels for each station were higher than the annual median rainfall levels because January is one of the wettest months of the year. There was also a difference between the rankings of some of the weather stations. For example, Killarney had the highest January median rainfall levels whereas Ardara had the highest for the annual median rainfall levels. Many of the differences between the January and annual rainfall levels were approximately 20mm. However, the differences seem to increase as the rainfall levels increased.

Conclusion

The median rainfall levels were calculated for 25 weather stations in Ireland for the month of January using data spanning from 1850 to 2014. A map was created which displayed the median values where each weather station was assigned a colour based on their median rainfall level. The main pattern evident was the west coast had the highest median rainfall values, followed by the midlands and the east had the lowest values. However, there were some exceptions to this pattern. The January median rainfall levels were higher than the annual median rainfall levels.

Bibliography

Mateus, C. and Coonan, B. (2023) Estimation of point rainfall frequencies in Ireland. Technical Note [online]. Available at: https://www.researchgate.net/profile/Carla-Mateus-4/publication/370599804_Estimation_of_point_rainfall_frequencies_in_Ireland/links/64590a535762c95ac380210e/Estimation-of-point-rainfall-frequencies-in-Ireland.pdf (accessed 12 January 2025).