Introduction

The precipitation is the most important data in the hydrology modeling. Analysis the precipitation data could improve the model. In this project, the interactive map could show the distribution of precipitation in the New York State. All the data is from the USGS, there are 35 stations were used in the project. The interactive map could indicate the mean, maximum, and minimum precipitation for each station. Also, the time series plots could illustrate the trend of the precipitation.

Materials and methods

All of the data is from the USGS. The period of each data is varied based on the station. The interval time is 15 minutes, thus it is important that transform the data to daily points. The processes are descried in following steps.

  • Download the data from the URL of USGS directly.
  • Data cleaning.
  • Insert the spatial information to each data point.
  • Time series plots and summarized table.
  • Combined plots and tables with interactive map.

Load the necessary packages:

library(leaflet)
library(ggplot2)
library(tidyverse)
library(mapview)
library(leafpop)
library(sf)
library(lubridate)
library(kableExtra)

Download and clean all required data :

##S1
S1 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=01359165&period=&begin_date=2018-12-14&end_date=2020-10-17",
                skip = 28,
                col.names = c("USGS","Station_N","Date","EST","P","Type"))
S1 = S1%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)

##S2
S2 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=01511000&period=&begin_date=2020-06-19&end_date=2020-10-17",
                skip = 28,
                col.names = c("USGS","Station_N","Date","EST","P","Type"))
S2 = S2%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S3
S3 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=03010820&period=&begin_date=2020-06-19&end_date=2020-10-17",
                skip = 28,
                col.names = c("USGS","Station_N","Date","EST","P","Type"))
S3 = S3%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S4
S4 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=03011020&period=&begin_date=2020-06-19&end_date=2020-10-17",
                skip = 28,
                col.names = c("USGS","Station_N","Date","EST","P","Type"))
S4 = S4%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S5
S5 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=421932078513701&period=&begin_date=2020-06-19&end_date=2020-10-17",
                skip = 28,
                col.names = c("USGS","Station_N","Date","EST","P","Type"))
S5 = S5%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S6
S6 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=421946078274901&period=&begin_date=2020-06-19&end_date=2020-10-17",
                skip = 28,
                col.names = c("USGS","Station_N","Date","EST","P","Type"))
S6 = S6%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S7
S7 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=420703079442501&period=&begin_date=2020-06-19&end_date=2020-10-17",
                skip = 28,
                col.names = c("USGS","Station_N","Date","EST","P","Type"))
S7 = S7%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S8
S8 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=421429079295601&period=&begin_date=2020-06-19&end_date=2020-10-17",
                skip = 28,
                col.names = c("USGS","Station_N","Date","EST","P","Type"))
S8 = S8%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S9
S9 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=421511079161701&period=&begin_date=2020-06-19&end_date=2020-10-17",
                skip = 28,
                col.names = c("USGS","Station_N","Date","EST","P","Type"))
S9 = S9%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S10
S10 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=01510000&period=&begin_date=2020-06-23&end_date=2020-10-17",
                 skip = 28,
                 col.names = c("USGS","Station_N","Date","EST","P","Type"))
S10 = S10%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##11
S11 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=01499500&period=&begin_date=2020-06-19&end_date=2020-10-17",
                 skip = 28,
                 col.names = c("USGS","Station_N","Date","EST","P","Type"))
S11 = S11%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S12
S12 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=01200000&period=&begin_date=2020-06-19&end_date=2020-10-17",
                 skip = 28,
                 col.names = c("USGS","Station_N","Date","EST","P","Type"))
S12 = S12%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S13
S13 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=04294413&period=&begin_date=2015-04-16&end_date=2020-10-17",
                 skip = 28,
                 col.names = c("USGS","Station_N","Date","EST","P","Type"))
S13 = S13%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S14
S14 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=04256500&period=&begin_date=2020-06-19&end_date=2020-10-17",
                 skip = 28,
                 col.names = c("USGS","Station_N","Date","EST","P","Type"))
S14 = S14%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S15
S15 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=04260500&period=&begin_date=2020-06-19&end_date=2020-10-17",
                 skip = 28,
                 col.names = c("USGS","Station_N","Date","EST","P","Type"))
S15 = S15%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S16
S16 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=411405074141501&period=&begin_date=2020-06-19&end_date=2020-10-17",
                 skip = 28,
                 col.names = c("USGS","Station_N","Date","EST","P","Type"))
S16 = S16%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S17
S17 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=0135980207&period=&begin_date=2018-12-15&end_date=2020-10-17",
                 skip = 28,
                 col.names = c("USGS","Station_N","Date","EST","P","Type"))
S17 = S17%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S18
S18 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=01376269&period=&begin_date=2019-02-22&end_date=2020-10-17",
                 skip = 28,
                 col.names = c("USGS","Station_N","Date","EST","P","Type"))
S18 = S18%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S19
S19 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=410518074020300&period=&begin_date=2020-06-19&end_date=2020-10-17",
                 skip = 28,
                 col.names = c("USGS","Station_N","Date","EST","P","Type"))
S19 = S19%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S20
S_20 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=424133077495701&period=&begin_date=2016-04-19&end_date=2020-10-17",
                  skip = 29,
                  col.names = c("USGS","Station_N","Date","EST","P","Type"))

S_20 = S_20%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S21
S_21 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=424421077495301&period=&begin_date=2015-10-15&end_date=2020-10-17",
                  skip = 28,
                  col.names = c("USGS","Station_N","Date","EST","P","Type"))
S_21 = S_21%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S22
S_22 = read.delim("https://waterdata.usgs.gov/ny/nwis/uv?cb_00045=on&format=rdb&site_no=425844077532901&period=&begin_date=2020-09-10&end_date=2020-10-17",
                  skip = 28,
                  col.names = c("USGS","Station_N","Date","EST","P","Type"))
S_22 = S_22%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S23
S_23 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=04229500&period=&begin_date=2020-06-19&end_date=2020-10-17",
                  skip = 28,
                  col.names = c("USGS","Station_N","Date","EST","P","Type"))
S_23 = S_23%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S24
S_24 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=410828074065801&period=&begin_date=2020-06-19&end_date=2020-10-17",
                  skip = 28,
                  col.names = c("USGS","Station_N","Date","EST","P","Type"))
S_24 = S_24%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S25
S_25 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=01354330&period=&begin_date=2018-12-11&end_date=2020-10-17",
                  skip = 28,
                  col.names = c("USGS","Station_N","Date","EST","P","Type"))
S_25 = S_25%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S26
S_26 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=01521000&period=&begin_date=2020-06-19&end_date=2020-10-17",
                  skip = 28,
                  col.names = c("USGS","Station_N","Date","EST","P","Type"))
S_26 = S_26%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S27
S_27 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=01523000&period=&begin_date=2020-06-19&end_date=2020-10-17",
                  skip = 28,
                  col.names = c("USGS","Station_N","Date","EST","P","Type"))
S_27 = S_27%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S28
S_28 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=01305575&period=&begin_date=2020-06-23&end_date=2020-10-17",
                  skip = 29,
                  col.names = c("USGS","Station_N","Date","EST","P","Type"))
S_28 = S_28%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S29
S_29 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=405925072165601&period=&begin_date=2020-06-19&end_date=2020-10-17",
                  skip = 28,
                  col.names = c("USGS","Station_N","Date","EST","P","Type"))
S_29 = S_29%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S30
S_30 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=01434498&period=&begin_date=2019-08-21&end_date=2020-10-17",
                  skip = 28,
                  col.names = c("USGS","Station_N","Date","EST","P","Type"))
S_30 = S_30%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S31
S_31 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=01310740&period=&begin_date=2020-06-19&end_date=2020-10-17",
                  skip = 28,
                  col.names = c("USGS","Station_N","Date","EST","P","Type"))
S_31 = S_31%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S32
S_32 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=01376515&period=&begin_date=2019-05-16&end_date=2020-10-17",
                  skip = 28,
                  col.names = c("USGS","Station_N","Date","EST","P","Type"))
S_32 = S_32%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(P = as.numeric(P))%>%
  mutate(Station_N = as.character(Station_N))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S33
S_33 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=01376520&period=&begin_date=2019-03-19&end_date=2020-10-17",
                  skip = 28,
                  col.names = c("USGS","Station_N","Date","EST","P","Type"))
S_33 = S_33%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(Station_N = as.character(Station_N))%>%
  mutate(P = as.numeric(P))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S34
S_34 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=01435000&period=&begin_date=2019-09-20&end_date=2020-10-17",
                  skip = 28,
                  col.names = c("USGS","Station_N","Date","EST","P","Type"))
S_34 = S_34%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(Station_N = as.character(Station_N))%>%
  mutate(P = as.numeric(P))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)
##S35
S_35 = read.delim("https://nwis.waterdata.usgs.gov/ny/nwis/uv/?cb_00045=on&format=rdb&site_no=04230380&period=&begin_date=2020-06-19&end_date=2020-10-17",
                  skip = 28,
                  col.names = c("USGS","Station_N","Date","EST","P","Type"))
S_35 = S_35%>%
  mutate(Date = floor_date(ymd_hm(Date),unit = "day"),.keep="unused")%>%
  mutate(Station_N = as.character(Station_N))%>%
  mutate(P = as.numeric(P))%>%
  group_by(Date,Station_N)%>%
  summarise(sum= sum(P))%>%
  filter(sum != 0)

Combined those data together:

all_sta = do.call("rbind",list(S1,S2,S3,S4,S5,S6,S7,S8,S9,S10,
                               S11,S12,S13,S14,S15,S16,S17,S18,
                               S19,S_20,S_21,S_22,S_23,S_24,S_25,
                               S_26,S_27,S_28,S_29,S_30,S_31,S_32,S_33,
                               S_34,S_35))
all_sta%>%
  head(10)%>%
  kable(digits = 2, align = 'c')%>%
  kable_styling(bootstrap_options = 
                  c("striped", "hover", "condensed", "responsive"))
Date Station_N sum
2018-12-14 1359165 0.75
2018-12-16 1359165 10.06
2018-12-17 1359165 3.01
2018-12-20 1359165 3.26
2018-12-21 1359165 22.81
2018-12-22 1359165 4.05
2018-12-24 1359165 0.50
2018-12-28 1359165 0.75
2018-12-31 1359165 8.59
2019-01-01 1359165 1.26

Plots:

all_sta_list = list(S12,S_28,S_31,S_25,S1,S17,S18,S_32,S_33,S_30,S_34,
                    S11,S10,S2,S_26,S_27,S3,S4,S_29,
                    S19,S_24,S16,S7,S8,S9,S5,
                    S6,S_23,S_35,S_20,S_21,S14,S_22,S15,
                    S13)
all_pt = list()
for (i in 1:35){
  pt=as.data.frame(all_sta_list[i])
  m=ggplot(pt,aes(as.Date(Date),sum))+
    geom_point(col = "red")+
    geom_smooth(method = 'loess',formula = y ~ x)+
    scale_x_date(date_labels = "%m-%Y")+
    labs(x="Date",
         y="Daily Precipitation (inches)",
         title = "Rainfall Plot")+
    theme_light()
  all_pt[[i]] <- m
  file_name = paste("S",i,".png",sep = "")
  #ggsave(file_name)
}

Example:

plot(all_pt[[1]])

Add the spatial information and summarized the data:

station = read_csv("E:/UB/Spatial Data Science/info.csv",
                   col_types = "cddd")
station%>%
  slice(1:10)%>%
  kable(digits = 2, align = 'c')%>%
  kable_styling(bootstrap_options = 
                  c("striped", "hover", "condensed", "responsive"))
Station_Name x y Station_N
HUDSON RIVER AT PORT OF ALBANY NY -73.45 42.37 1.359165e+06
WHITNEY POINT LAKE AT WHITNEY POINT NY -75.58 42.20 1.511000e+06
ALLEGHENY RIVER AT OLEAN NY -78.27 42.04 3.010820e+06
ALLEGHENY RIVER AT SALAMANCA NY -78.43 42.09 3.011020e+06
CATTARAUGUS RAIN GAGE -78.51 42.19 4.219321e+14
FRANKLINVILLE RAIN GAGE -78.27 42.19 4.219461e+14
FINDLEY LAKE RAIN GAGE -79.44 42.07 4.207031e+14
MAYVILLE RAIN GAGE -79.30 42.14 4.214291e+14
SINCLAIRVILLE RAIN GAGE NEAR SINCLAIRVILLE NY -79.16 42.15 4.215111e+14
OTSELIC RIVER AT CINCINNATUS NY -75.54 42.32 1.510000e+06
station = station%>%
  mutate(Station_N = as.character(Station_N))
all_sta_info = all_sta%>%
  group_by(Station_N)%>%
  summarise(Ave = mean(sum),
            Max = max(sum),
            Min = min(sum))%>%
  left_join(station,.by="Station_N")
## `summarise()` ungrouping output (override with `.groups` argument)
## Joining, by = "Station_N"
all_sta_info %>% 
  slice(1:35) %>% #show only 1:n rows
  kable(digits=2,align="c")%>% 
  kable_styling(bootstrap_options = 
                  c("striped", "hover", "condensed", "responsive"))
Station_N Ave Max Min Station_Name x y
1200000 0.02 0.09 0.01 TENMILE RIVER NEAR GAYLORDSVILLE, CT -73.55 41.73
1305575 0.24 1.47 0.01 GREAT SOUTH BAY AT WATCH HILL ON FIRE ISLAND NY -73.08 40.66
1310740 0.53 5.97 0.01 REYNOLDS CHANNEL AT POINT LOOKOUT NY -73.59 40.59
1354330 0.29 3.11 0.01 MOHAWK RIVER AT LOCK 8 NEAR SCHENECTADY NY -73.59 42.49
1359165 2.25 28.90 0.01 HUDSON RIVER AT PORT OF ALBANY NY -73.45 42.37
135980207 0.24 2.05 0.01 HUDSON RIVER NEAR SCHODACK LANDING NY -73.46 42.30
1376269 0.23 1.82 0.01 HUDSON RIVER AT PIERMONT NY -73.53 41.02
1376515 0.25 3.17 0.00 HUDSON RIVER AT PIER 84 AT NEW YORK NY -74.00 40.76
1376520 3.63 29.40 0.00 HUDSON RIVER AT PIER 26 AT NEW YORK NY -74.02 40.72
1434498 0.39 3.03 0.01 WEST BRANCH NEVERSINK RIVER AT CLARYVILLE NY -72.28 41.55
1435000 0.36 2.82 0.01 NEVERSINK RIVER NEAR CLARYVILLE NY -74.35 41.53
1499500 0.27 1.08 0.01 EAST SIDNEY LAKE AT EAST SIDNEY NY -75.13 42.19
1510000 0.18 0.99 0.01 OTSELIC RIVER AT CINCINNATUS NY -75.54 42.32
1511000 0.18 1.04 0.01 WHITNEY POINT LAKE AT WHITNEY POINT NY -75.58 42.20
1521000 0.11 0.74 0.01 ARKPORT RESERVOIR NEAR ARKPORT NY -77.43 42.23
1523000 0.18 1.16 0.01 ALMOND LAKE NEAR ALMOND NY -77.42 42.21
3010820 0.15 0.78 0.01 ALLEGHENY RIVER AT OLEAN NY -78.27 42.04
3011020 0.19 1.14 0.01 ALLEGHENY RIVER AT SALAMANCA NY -78.43 42.09
405925072165601 0.11 1.08 0.01 RAIN GAGE NEAR SAG HARBOR NY -72.17 40.99
410518074020300 0.43 1.55 0.01 Nanuet USGS unheated rain gage NY -74.02 41.05
410828074065801 0.40 1.23 0.01 Suffern USGS unheated rain gage NY -74.07 41.08
411405074141501 0.44 1.52 0.04 Sterling Forest USGS unheated rain gage NY -74.14 41.14
420703079442501 0.21 0.67 0.02 FINDLEY LAKE RAIN GAGE -79.44 42.07
421429079295601 0.24 0.72 0.01 MAYVILLE RAIN GAGE -79.30 42.14
421511079161701 0.26 0.85 0.01 SINCLAIRVILLE RAIN GAGE NEAR SINCLAIRVILLE NY -79.16 42.15
421932078513701 0.17 0.66 0.01 CATTARAUGUS RAIN GAGE -78.51 42.19
421946078274901 0.16 0.87 0.01 FRANKLINVILLE RAIN GAGE -78.27 42.19
4229500 0.22 0.78 0.01 HONEOYE CREEK AT HONEOYE FALLS NY -77.35 42.57
4230380 0.17 0.74 0.01 OATKA CREEK AT WARSAW NY -78.08 42.44
424133077495701 0.23 2.94 0.01 ALFRED FARMS EDGE OF FIELD MET STATION AT SONYEA -77.50 42.41
424421077495301 0.22 2.17 0.01 NY-SW1 MERRIMAC FARMS EDGE OF FIELD, E GROVELAND -77.50 42.44
4256500 0.09 0.42 0.01 STILLWATER RESERVOIR NEAR BEAVER RIVER NY -75.03 43.53
425844077532901 0.17 0.78 0.01 Local number, Lv-333, near Caledonia NY -77.53 42.58
4260500 0.01 0.02 0.01 BLACK RIVER AT WATERTOWN NY -75.55 43.59
4294413 0.28 5.32 0.01 LAKE CHAMPLAIN AT PORT HENRY NY -73.27 44.03

Results

Transform the data to the spatial data prepared for the interactive map.

all_sta_geo = st_as_sf(all_sta_info, coords = c("x", "y"), crs = 4326)

all_sta_info = all_sta_info%>%
  select(-x,-y)

m = leaflet() %>%
  addTiles() %>%
  addCircleMarkers(data = all_sta_geo,
                   group = "Information",
                   popup = popupTable(all_sta_info))%>%
  addCircleMarkers(data =all_sta_geo ,
                   group = "Plot",
                   popup = popupGraph(all_pt,type = "png"))%>%
  addLayersControl(overlayGroups = c("Information","Plot"))
m  # a map with the default OSM tile layer

Map of Precipitation in NY

Conclusions

This project visualize the distribution of precipitation in New York State. Those plots indicated a trend of precipitation for each station directly. Also, the information table summarized the basic information of precipitation, like mean, maximum, and minimum. The interactive map are more readable, it could show the trend and spatial distribution synchronously.

References

All sources are cited in a consistent manner.