Title :” Ireland’s Median Rainfall in january 1850-2014

Author : Dimitri Tiani

Date: 01/17/2025

format : htlm

Self-contained-math : true

Self-contained: true


R assignment

###set working directory where the data will be taken from and saved from

setwd(‘C:/Users/27736/Desktop/R data/Class Materials-20241230’)

###load library (sf) to read simple feauture ### load and read the data

load (‘Rainfall.Rdata’) library (sf)

station <- read_sf (‘weather_stations.geojson’)

###check the structure of the data

str (station)

load library (dplyr) this is done in order to compute the median by grouping

load library (tidyverse)

###Calculating median for the 25 station. library (dplyr) library (tidyverse)

Rain_med <- rain %>% filter(Month == “Jan” & Year >= 1850 & Year <= 2014) %>% group_by(Station) %>% summarise(medrainfall = median(Rainfall, na.rm = TRUE))

visual representation to se how the median distributions differs from station to station from january 1850 to 2014.

barplot(Rain_med\(medrainfall,names= Rain_med\)Station, las= 3, col = “blue”)

the next step is to join median rainfall obtained to station in order to get coordinates for mapping purpose.

station %>% left_join(Rain_med)-> station_median

the next step will be to represent the different by first exporting the map of ireland from and inserting its coordinate for the map to be drawn on R

library(tmap) library(sf)

stations_sf <- station_median %>% st_as_sf(coords=c(‘Long’,‘Lat’),crs=4326) tmap_mode(‘view’) + tm_shape(stations_sf) + tm_bubbles(size = “medrainfall”, col = “medrainfall”, palette = “viridis”, title.size = “Median Rainfall”, title.col = “Median Rainfall”) + tm_layout(title = “Median Rainfall by Station”, legend.outside = TRUE)

Notes on observable pattern

It observable that stations on the west coast have higher median than those in the interior and the eastern side of the Island of Ireland on average. another discerning pattern is that Station that are close together having median within the same range of rainfall or within range below or above mostly therefore as Waldo Tobler has stated places that are close together have spatial similarity to place that are far apart .

part 2

load the rainfall data along with some initial library load up

load (‘Rainfall.Rdata’)

###load dplyr and tidyverse for spatial data manipulation

library (dplyr) library (tidyverse) ###load sp for handling spatial data

library (sp) ### Install and load the drygraph which is great visual representation of time series.

install.packages(“dygraphs”) library(dygraphs) ### summary of all the four stations.

Cork_ts <- rain %>% filter(Station == “Cork Airport”) %>% group_by(Year, Month) %>% summarise(Rainfall = sum(Rainfall, na.rm = TRUE), .groups = “drop”) %>% pull(Rainfall) %>% ts(start = c(1850, 1), frequency = 12)

rain %>% filter(Station==“Belfast”) %>% summarise(Rainfall=sum(Rainfall),.by=c(Month)) %>% pull(Rainfall) %>% ts(start=c(1850,1),freq=12) -> bel_ts

rain %>% filter(Station==“Dublin Airport”) %>% summarise(Rainfall=sum(Rainfall),.by=c(Month)) %>% pull(Rainfall) %>% ts(start=c(1850,1),freq=12) -> dub_ts ### combine all the Rainfall time series into one serie for the dygraph visual represetation bod_ts <- cbind(bel_ts,Cork_ts,dub_ts)

Gal_ts <- rain %>% filter(Station == “University college Galway”) %>% group_by(Month) %>% summarise(Rainfall = sum(Rainfall, na.rm = TRUE), .groups = “drop”) %>% pull(Rainfall) %>% ts(start = c(1850, 1), frequency = 12)

bod_ts %>% dygraph(width = 900, height = 300) %>% dyRangeSelector() beducoal_ts<-cbind(bel_ts,dub_ts,Cork_ts,Gal_ts) View(beducoal_ts) ### the next step is to represent time serie using a dygraphy and dyrangeSelector

beducoal_ts %>% dygraph(width=900,height=300) %>% dyRangeSelector()