The data used originated from the
weather_stations.geojson file available on the Moodle page
for GY672: GY672 files. This file contains monthly rainfall records
for Ireland from 1850 to 2014, as well as being a geographical features
file with mapping coordinates. Other points of information included in
this file include: the weather station and county for each data point,
the data point source, and easting/northing values. The purpose of this
assignment was to analyse the median rainfall for each weather station
in the month of January. In order to calculate and investigate this, the
original data must first be manipulated.
The data was first imported and manipulated so that rainfall records for the month of January were isolated.
setwd("/Users/elizabeth/Documents/GY672_Spatial_and_Temporal_Data_with_R /GY672_A2")
#install.packages("sf")
library(sf)
## Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
#install.packages("rjson")
library(rjson)
W_S<- st_read("weather_stations.geojson")
## Reading layer `weather_stations' from data source
## `/Users/elizabeth/Documents/GY672_Spatial_and_Temporal_Data_with_R /GY672_A2/weather_stations.geojson'
## using driver `GeoJSON'
## Simple feature collection with 49500 features and 11 fields
## Geometry type: POINT
## Dimension: XY
## Bounding box: xmin: 46633.44 ymin: 59756.08 xmax: 330201.3 ymax: 457227.9
## Projected CRS: TM65 / Irish Grid
counties<-st_read("counties.geojson")
## Reading layer `counties' from data source
## `/Users/elizabeth/Documents/GY672_Spatial_and_Temporal_Data_with_R /GY672_A2/counties.geojson'
## using driver `GeoJSON'
## Simple feature collection with 40 features and 2 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: 17528.59 ymin: 19537.25 xmax: 366403.6 ymax: 466923.2
## Projected CRS: TM65 / Irish Grid
station_list_A2<- list("Ardara", "Armagh", "Athboy", "Belfast", "Birr", "Cappoquinn", "Cork Airport", "Derry", "Drumsna", "Dublin Airport", "Enniscorthy", "Foulksmills", "Killarney", "Malin Head", "Markree Castle", "Mullingar", "Phoenix Park", "Portlaw", "Rathdrum", "Roches Point", "Shannon Airport", "Strokestown", "University College Galway", "Valentia", "Waterford")
W_S_jan<- W_S[W_S$Month=="Jan",]
Then the rainfall data for each station was extracted and the median calculated. This was compiled into a data frame containing the median January rainfall for each station.
x=NULL
y=NULL
z=NULL
for (i in station_list_A2) {x = W_S_jan[W_S_jan$Station == i, c(4,1,3)]
y = c(i, median(x$Rainfall))
z = rbind(z,y)} #for every station, print the median rainfall for January
The coordinates/geometry for each station were also then extracted, and added to the compiled median data.
c=NULL
W_S_coord=NULL
for (i in station_list_A2) {c<- W_S[W_S$Station == i, c(4, 12)]
W_S_coord<- rbind(W_S_coord, c[1,])} #for every station, print the coordinates
jan<-data.frame(z) #define as a data frame
colnames(jan)<- c("station", "median.rainfall")
jan$median_rainfall<- as.numeric(as.character(jan$median.rainfall)) #ensure R recognises readings as numeric values
W_S_med_jan_coord<- cbind(W_S_coord, jan$median_rainfall) #join median and coordinate data together
row.names(W_S_med_jan_coord)<-NULL
colnames(W_S_med_jan_coord)<- c("Station", "median.rainfall.january", "geometry")
head(W_S_med_jan_coord)
## Simple feature collection with 6 features and 2 fields
## Geometry type: POINT
## Dimension: XY
## Bounding box: xmin: 181346.8 ymin: 104250.6 xmax: 330201.3 ymax: 393612.6
## Projected CRS: TM65 / Irish Grid
## Station median.rainfall.january geometry
## 1 Ardara 171.6 POINT (181346.8 393612.6)
## 2 Armagh 75.0 POINT (288422 345452.4)
## 3 Athboy 87.1 POINT (270828.9 261661)
## 4 Belfast 102.1 POINT (330201.3 363154.6)
## 5 Birr 77.5 POINT (208040.8 203268.4)
## 6 Cappoquinn 147.4 POINT (213676 104250.6)
To analyse and compare these medians across the country of Ireland, the points were to be plotted, allowing for visual analysis of any trends in the data. The station coordinates were plotted alongside county border coordinates. Another layer was added showing the variation in median per station with a colour gradient.
base_map2<- leaflet::providers$CartoDB.DarkMatter
tm_basemap(base_map2) + tm_shape(counties) + tm_borders(col = "white", lwd = 0.1) + tm_shape(W_S_coord) + tm_bubbles(col = "deepskyblue", size = 0.1) +
tm_text("Station", size = 0.7, col = "white", shadow = TRUE) +
tm_shape(W_S_med_jan_coord) + tm_bubbles(col = "median.rainfall.january", size = 0.2, style = "cont", palette = "YlGnBu") #create three tmap layers: one with county outlines, one with station locations and names, one with median rainfall level per station
A graph was also created to summarise the overall trend of rainfall in Ireland for January. This allowed for clear visualisation of the overall range in rainfall levels across the stations.
ggplot(W_S_med_jan_coord,aes(x=median.rainfall.january, y=Station)) + geom_point() +
labs(y="Station", x="Median Rainfall (cm)", title="Median Rainfall in January") +
theme_minimal() + theme(text=element_text(family="mono")) + ggeasy::easy_center_title()
As seen by the individual plotting of station median rainfall, levels range from 63.0cm in Dublin Airport to 177.7cm recorded in Killarney. This is also visible in the map showing median rainfall: within the colour gradient, Dublin Airport shows to have the palest shade of yellow, and Killarney exhibits the deepest hue of blue, aligning with the recorded data. Stations exhibiting greater volumes of rainfall appear to be located in coastal regions (e.g. Valentia, Ardara, Killarney). Stations with lower volumes of rainfall appear in Central Ireland and along the East and East Coast. Ireland receives the majority of its weather patterns from the Atlantic Ocean, meeting Ireland in the West, South West and South. Therefore it is no surprise that these exposed coastal areas receive the brunt of incoming precipitation. Coastal areas in the East, such as Dublin receive less rainfall, and are also sheltered by the Wicklow mountains. This may also explain why Shannon Airport shows lower levels, as it may also be sheltered by surrounding mountain ranges (Carlier et al., 2021).
Carlier, J., Doyle, M., Finn, J.A., Ó hUallacháin, D., Moran, J. (2021) A landscape classification map of Ireland and its potential use in national land use monitoring. Journal of Environmental Management. 289:112498.