NCG 602A: Climate Change Msc Assignment

NCG 602A: Climate Change Msc Assignment

Reproducible rainfall map of Ireland using Rmarkdown

Set working directory
setwd("C:\\Users\\admin\\Desktop\\CC_Ass")
getwd()
Loading the required libraries
library(leaflet)
library(dplyr)
Loading rainfall data and viewing the first few rows
load("rainfall.RData")
head(stations)
# A tibble: 6 x 9
      Station Elevation Easting Northing   Lat  Long    County Abbreviation      Source
        <chr>     <int>   <dbl>    <dbl> <dbl> <dbl>     <chr>        <chr>       <chr>
1      Athboy        87  270400   261700 53.60 -6.93     Meath           AB Met Eireann
2 Foulksmills        71  284100   118400 52.30 -6.77   Wexford            F Met Eireann
3   Mullingar       112  241780   247765 53.47 -7.37 Westmeath            M Met Eireann
4     Portlaw         8  246600   115200 52.28 -7.31 Waterford            P Met Eireann
5    Rathdrum       131  319700   186000 52.91 -6.22   Wicklow           RD Met Eireann
6 Strokestown        49  194500   279100 53.75 -8.10 Roscommon            S Met Eireann

head(rain)
# A tibble: 6 x 4
   Year  Month Rainfall Station
  <dbl> <fctr>    <dbl>   <chr>
1  1850    Jan    169.0  Ardara
2  1851    Jan    236.4  Ardara
3  1852    Jan    249.7  Ardara
4  1853    Jan    209.1  Ardara
5  1854    Jan    188.5  Ardara
6  1855    Jan     32.3  Ardara
summarise the median rainfall for Jan for all stations
rain %>% group_by(Year,Station) %>%  filter(Month=='Jan') %>%
  summarise(medrr=median(Rainfall)) -> medrr_summary

head(medrr_summary)
A tibble: 6 x 3
Groups:   Year [1]
   Year    Station medrr
  <dbl>      <chr> <dbl>
1  1850     Ardara 169.0
2  1850     Armagh  92.5
3  1850     Athboy  87.1
4  1850    Belfast 115.7
5  1850       Birr  93.3
6  1850 Cappoquinn 156.8

medrr_summary %>% left_join(stations) -> station_medians
head(station_medians)
A tibble: 6 x 11
Groups:   Year [1]
   Year    Station medrr Elevation  Easting Northing   Lat  Long    County
  <dbl>      <chr> <dbl>     <int>    <dbl>    <dbl> <dbl> <dbl>     <chr>
1  1850     Ardara 169.0        15 180787.7 394679.0 54.79 -8.29   Donegal
2  1850     Armagh  92.5        62 287831.3 345772.0 54.35 -6.64    Armagh
3  1850     Athboy  87.1        87 270400.0 261700.0 53.60 -6.93     Meath
4  1850    Belfast 115.7       115 329623.4 363141.3 54.50 -5.99    Antrim
5  1850       Birr  93.3        73 208016.8 203400.5 53.08 -7.88    Offaly
6  1850 Cappoquinn 156.8        76 213268.9 104799.9 52.19 -7.80 Waterford
# ... with 2 more variables: Abbreviation <chr>, Source <chr>
Color mapping creation
color_map <- colorNumeric('Spectral',station_medians$medrr)
previewColors(color_map,fivenum(station_medians$medrr))
Colour map for median rainfall of Ireland.

Colour map for median rainfall of Ireland.

Map creation
leaflet(data=station_medians,height=430,width=600) %>% 
  addProviderTiles('CartoDB.Positron') %>% 
  setView(-8,53.6,6) %>% 
  addCircleMarkers(fillColor = ~color_map(medrr),weight=0,fillOpacity = 0.85) %>% 
  addLegend(pal=color_map,values=~medrr,title = "Median Rainfall",position='bottomleft')
Long term median Rainfall map of Ireland from 1850 - 2014 .

Long term median Rainfall map of Ireland from 1850 - 2014 .

Summary

The map shows the spatial distribution of long term median monthly rainfall amount (1850 - 2014) for January over 25 stations in Ireland using leaflet and dplyr packages in R.The median rainfall ranged between 0 and 350mm. The lowest median rainfall was found in the Northern Ireland around Belfast and east of Ireland around Dublin, and highest amount in the south-west around Kerry.