# %>% and stuff
library(tidyverse)
# handle spatial data
library(sf)
# 'nice' color palettes
library(RColorBrewer)
# plotting libraries
library(ggplot2)
library(plotly)
# The rainfall data - as in last lecture
load("rainfall.RData")
Working with spatial data - 1
The stations data frame gives geographical information about the weather stations:
stations
## # A tibble: 25 x 9
## Station Elevation Easting Northing Lat Long County Abbreviation
## <chr> <int> <dbl> <dbl> <dbl> <dbl> <chr> <chr>
## 1 Athboy 87 270400 261700 53.6 -6.93 Meath AB
## 2 Foulks… 71 284100 118400 52.3 -6.77 Wexfo… F
## 3 Mullin… 112 241780 247765 53.5 -7.37 Westm… M
## 4 Portlaw 8 246600 115200 52.3 -7.31 Water… P
## 5 Rathdr… 131 319700 186000 52.9 -6.22 Wickl… RD
## 6 Stroke… 49 194500 279100 53.8 -8.1 Rosco… S
## 7 Univer… 14 129000 225600 53.3 -9.06 Galway UCG
## 8 Drumsna 45 200000 295800 53.9 -8 Leitr… DAL
## 9 Ardara 15 180788. 394679. 54.8 -8.29 Doneg… AR
## 10 Armagh 62 287831. 345772. 54.4 -6.64 Armagh A
## # … with 15 more rows, and 1 more variable: Source <chr>
Working with spatial data - 2
Make this into a simplefeatures spatial object
This is like a data frame but has geographical structure
Here each station is represented as a point with a latitude and longitude