Using data from https://www.ncei.noaa.gov, precipitation data was collated from 4 weather stations on the islands of Hawaii. The maps below demonstrates precipitation in inches at each of the weather stations for the years 1980 (top map) and 2015 (bottom map). Hovering over the data points shows the annual rainfall at that particular weather station.
The spatial units in the graphs are longitude and latitude coordinates of the selected Hawaiian weather stations.
By examining this data, we can compare the location of the weather stations to each other as well as the amount of rainfall received at each station.
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
library(ggdendro)
Warning: package 'ggdendro' was built under R version 4.0.5
library(mapproj)
Warning: package 'mapproj' was built under R version 4.0.5
Loading required package: maps
#make average prcp per yearweather$year <-substr(weather$DATE, 1,4)p <- weather %>%group_by(STATION, NAME, year) %>%summarise(prcp=mean(PRCP),Latitude=mean(LATITUDE), Longitude=mean(LONGITUDE))
`summarise()` regrouping output by 'STATION', 'NAME' (override with `.groups` argument)
#New data sets for desired yearsq <- p[p[,3] ==1980,]w <- p[p[,3] ==2015,]library(leaflet)
Warning: package 'leaflet' was built under R version 4.0.5
library(leafletCN)# define color palettepal <-colorNumeric(palette ="magma",domain = p$PRCP)
Warning: Unknown or uninitialised column: `PRCP`.
#create new labels for annual prcp averagelabsq <-lapply(seq(nrow(q)),function(i){paste0("Annual Prcp average (inches): ", as.character(round(q[i, 4],4)))})leaflet(q) %>%addTiles() %>%addMarkers(~Longitude, ~Latitude, label =~lapply(labsq, htmltools::HTML)) %>%setView(lng =-158, lat =20, zoom =6)
#create new labels for annual prcp averagelabsw <-lapply(seq(nrow(w)),function(i){paste0("Annual Prcp average (inches): ", as.character(round(w[i, 4],4)))})
LIHUE WEATHER SERVICE OFFICE AIRPORT 1020.1, HI US
21.98048
-159.3386
4.560000
2.510833
Rainfall totals remained relatively constant between the years 1980 and 2015 as shown in the tabular view. The chart below compares rainfall totals over time. Over the time span, the relative ranking of rainfall on the Hawaiian islands remains the same with Station USW00021504 consistently recievivng more rainfall than the other stations.
library(ggplot2)library(plotly)rain <-ggplot(data = p, aes(x =as.numeric(year), y = prcp, color = STATION)) +geom_point() +geom_line() +xlab("Year") +ylab("Precipitation Inches") ggplotly(rain)