Assignment

  1. Creating a map of rainfall in Ireland for the 25 weather stations, colour coding the symbol for each station according to its median rainfall level in January.
#required libraries
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
library(tmap)
## Breaking News: tmap 3.x is retiring. Please test v4, e.g. with
## remotes::install_github('r-tmap/tmap')
library(sf)
## Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.3.1; sf_use_s2() is TRUE
library(RColorBrewer)
library(sp)
library(leaflet)

Data Description and Context

The dataset contains rainfall data from 25 weather stations across Ireland, including columns such as Year, Month, Rainfall, Station, Elevation, Easting, Northing, County, Abbreviation, Source, coast_dist, and geometry. It is used to analyze and map the median rainfall levels for January, highlighting variations in rainfall across the country.

Data of Weather Stations :

ws= st_read("C:/Users/saiye/Downloads/weather_stations.geojson",quiet=TRUE)

File used in this analysis: weather_stations.geojson

Data-Adjustments

Data Cleaning:

To ensure the dataset is accurate and ready for analysis, it is essential to remove any rows containing missing values. Missing data can lead to errors or biases in the analysis, and removing these rows ensures consistency and reliability in the results.
gj <- na.omit(ws)

Processing and Mapping Median Rainfall Data for January

    #Filter January data
jan_data <- gj %>% filter(Month == "Jan")

    # Compute median rainfall for each station
median_rainfall <- jan_data %>%
  group_by(Station) %>%
  summarize(median_rainfall = median(Rainfall, na.rm = TRUE)) %>%
  ungroup()

    # Join median rainfall back to geometry
gj <- gj %>%
  st_join(median_rainfall, join = st_intersects)

station_means <- gj %>% select(Station.x, median_rainfall, geometry)

    # Create interactive map
tmap_mode("view")
## tmap mode set to interactive viewing

1. Filter January Data: jan_data <- gj %>% filter(Month == "Jan") Filters the dataset gj to include only the rows where the month is January, isolating the relevant data for analysis.

2. Compute Median Rainfall for Each Station: Groups the January data by each station and calculates the median rainfall for each station. The resulting dataset, median_rainfall, contains the station names and their corresponding median rainfall levels.

3. Join Median Rainfall with Geometry: Combines the median_rainfall data with the spatial geometry of the weather stations from gj. This step associates the median rainfall data with the spatial locations for mapping.

4. Create a Simplified Dataset for Mapping: Selects the relevant columns (Station.x, median_rainfall, and geometry) from the joined dataset to create a simplified dataset, station_means, specifically for mapping.

5. Set Map Mode to Interactive: tmap_mode("view") Switches the tmap package into interactive mode, enabling the creation of an interactive map where users can explore the data visually.

Interactive January Rainfall Map of Ireland

tm_start <- tm_shape(station_means) +
  tm_dots(
    col = "median_rainfall",
    palette = "viridis", # a colorblind-friendly palette
    size = 0.3, 
    popup.vars = c("Station Name" = "Station.x", "Median Rainfall (mm)" = "median_rainfall"),
    title = "Rainfall Intensity (Median)"
  ) +
  tm_layout(
    title = "Rainfall Distribution in January across Ireland", 
    legend.outside = TRUE,
    legend.outside.position = "right",
    frame = TRUE, #border around the map for aesthetics
    title.size = 1.5 
  )

# Convert to interactive leaflet map
interactive_map <- tmap_leaflet(tm_start) %>%
  addScaleBar(position = "bottomright") %>% #scale bar
  addMiniMap(zoomLevelOffset = -3, toggleDisplay = TRUE, minimized = FALSE)

# View the map
interactive_map

This code generates an interactive map that visualizes the median rainfall levels across 25 weather stations in Ireland for January. The stations are color-coded based on rainfall intensity using a colorblind-friendly palette,viridis. The map displays pop-up information, including the station name and corresponding median rainfall (in mm). It also includes a scale bar and a mini map for easier navigation, with the main title reflecting the rainfall distribution across the country. The layout features a border around the map for aesthetics, and the legend is positioned outside to the right for better clarity.

Ireland’s January Rainfall Patterns: Key Insights

The interactive map visualizes the median rainfall across Ireland in January using a viridis color palette, which ranges from dark purple (low rainfall) to bright yellow (high rainfall), offering a colorblind-friendly representation.

Dark Purple: Represents the lowest rainfall (60–80 mm) in the east 🌞.

Bright Yellow: Represents the highest rainfall (160–180 mm) in the southwest 🌧️.

Key Observations:

High Rainfall in the Southwest: Stations like Killarney (~177.7 mm) and Valentia (~166 mm) are shown in yellow, reflecting the highest rainfall due to Atlantic Ocean moisture and the Orographic Effect (moist air rising over mountains).

Lower Rainfall in the East: Stations like Dublin Airport (~63 mm) and Phoenix Park (~67.6 mm) appear in dark purple, indicating the driest regions due to the Rain-Shadow Effect, where mountains block moisture from the west.

Coastal Influence: Coastal areas in the southwest (e.g., Kerry and Cork) have higher rainfall, while eastern coastal regions (e.g., Waterford) show moderate rainfall in darker shades of purple and green.

Inland Areas: Regions like Birr (~77.5 mm) receive lower rainfall, reflected in darker shades, as they are more inland and shielded from the Atlantic’s moisture.

Conclusion

This process effectively visualizes the median rainfall levels across Ireland’s weather stations for January. By filtering and processing the data, calculating the median rainfall, and integrating spatial information, we created an interactive map that offers clear insights into rainfall distribution, enhancing data accessibility and understanding.

Name: Saiyed Mohammad Saihan

Student ID: 24251447

Course Name: Advanced Topics in Geocomputation

Course Code: NCG618\[A\] (24-25:S1)