Gaayathri Iyer
1/19/2020
This is a simple Shiny web application which visualizes the Water Data of Colorado State, USA for better understanding. The application takes inputs like the type of station, county, date and time and renders plots for better visualization. The inputs are inter-dependent, for example, selecting a county will auto populate the dependent fields like date and time. The interactive plots are generated using Plotly.
User can select the input by clicking the inverted triangle. Hovering over the plot will give the details of the data rendered.
Data is in the form of JSON file. Here are the data types and a snapshot of the raw data.
## 'data.frame': 1000 obs. of 19 variables:
## $ station_name : chr "NORTH PLATTE RIVER NEAR NORTHGATE, CO" "LA VETA #2 RETURN FLOW" "ALFALFA RUN BELOW FRUIT GROWERS RESERVOIR, CO" "FARMERS INDEPENDENT DITCH" ...
## $ div : chr "6" "2" "4" "1" ...
## $ dwr_abbrev : chr "NPLGATCO" "LVRET2CO" "ALFFRUCO" "FRMDITCO" ...
## $ data_source : chr "U.S. Geological Survey" "Co. Division of Water Resources" "Co. Division of Water Resources" "Cooperative Program of CDWR, NCWCD & LSPWCD" ...
## $ usgs_station_id : chr "06620000" NA NA NA ...
## $ amount : chr "321.00" "0.00" "0.06" "0.00" ...
## $ :@computed_region_nku6_53ud: chr "1007" "1006" "1443" "1072" ...
## $ station_type : chr "Stream" "Stream" "Stream" "Diversion" ...
## $ wd : chr "47" "16" "40" "2" ...
## $ date_time : chr "2019-10-30T05:45:00.000" "2019-12-29T21:30:00.000" "2019-12-29T21:15:00.000" "2019-12-29T21:00:00.000" ...
## $ county : chr "JACKSON" "HUERFANO" "DELTA" "WELD" ...
## $ variable : chr "DISCHRG" "DISCHRG" "DISCHRG" "DISCHRG" ...
## $ station_status : chr "Active" "Active" "No gage height recorded, gage is closed for winter, seasonal site" "Active" ...
## $ flag : chr NA NA "Ssn" NA ...
## $ stage : chr NA NA "0.08" NA ...
## $ location.latitude : chr "40.936639" "37.66117" "38.826668" "40.205724" ...
## $ location.needs_recoding : logi FALSE FALSE FALSE FALSE FALSE FALSE ...
## $ location.longitude : chr "-106.339194" "-104.695011" "-107.955276" "-104.826171" ...
## $ http_linkage.url : chr "https://waterdata.usgs.gov/nwis/uv?06620000" "https://dwr.state.co.us/SurfaceWater/data/detail_graph.aspx?ID=LVRET2CO&MTYPE=DISCHRG" "https://dwr.state.co.us/SurfaceWater/data/detail_graph.aspx?ID=ALFFRUCO&MTYPE=DISCHRG" "https://dwr.state.co.us/SurfaceWater/data/detail_graph.aspx?ID=FRMDITCO&MTYPE=DISCHRG" ...
## station_name div dwr_abbrev
## 1 NORTH PLATTE RIVER NEAR NORTHGATE, CO 6 NPLGATCO
## 2 LA VETA #2 RETURN FLOW 2 LVRET2CO
## 3 ALFALFA RUN BELOW FRUIT GROWERS RESERVOIR, CO 4 ALFFRUCO
## 4 FARMERS INDEPENDENT DITCH 1 FRMDITCO
## 5 FRYINGPAN RIVER NEAR THOMASVILLE, CO. 5 FRYTHOCO
## 6 ALAMOSA RIVER ABOVE TERRACE RESERVOIR, CO. 3 ALATERCO
## data_source usgs_station_id amount
## 1 U.S. Geological Survey 06620000 321.00
## 2 Co. Division of Water Resources <NA> 0.00
## 3 Co. Division of Water Resources <NA> 0.06
## 4 Cooperative Program of CDWR, NCWCD & LSPWCD <NA> 0.00
## 5 Co. Division of Water Resources 09078600 26.60
## 6 Co. Division of Water Resources 08236000 0.00
## :@computed_region_nku6_53ud station_type wd date_time county
## 1 1007 Stream 47 2019-10-30T05:45:00.000 JACKSON
## 2 1006 Stream 16 2019-12-29T21:30:00.000 HUERFANO
## 3 1443 Stream 40 2019-12-29T21:15:00.000 DELTA
## 4 1072 Diversion 2 2019-12-29T21:00:00.000 WELD
## 5 1063 Stream 38 2019-12-29T21:30:00.000 PITKIN
## 6 1440 Stream 21 2019-12-29T21:15:00.000 CONEJOS
## variable station_status
## 1 DISCHRG Active
## 2 DISCHRG Active
## 3 DISCHRG No gage height recorded, gage is closed for winter, seasonal site
## 4 DISCHRG Active
## 5 DISCHRG Active
## 6 DISCHRG Active
## flag stage location.latitude location.needs_recoding location.longitude
## 1 <NA> <NA> 40.936639 FALSE -106.339194
## 2 <NA> <NA> 37.66117 FALSE -104.695011
## 3 Ssn 0.08 38.826668 FALSE -107.955276
## 4 <NA> <NA> 40.205724 FALSE -104.826171
## 5 <NA> 1.73 39.345262 FALSE -106.673818
## 6 <NA> -0.50 37.374474 FALSE -106.332877
## http_linkage.url
## 1 https://waterdata.usgs.gov/nwis/uv?06620000
## 2 https://dwr.state.co.us/SurfaceWater/data/detail_graph.aspx?ID=LVRET2CO&MTYPE=DISCHRG
## 3 https://dwr.state.co.us/SurfaceWater/data/detail_graph.aspx?ID=ALFFRUCO&MTYPE=DISCHRG
## 4 https://dwr.state.co.us/SurfaceWater/data/detail_graph.aspx?ID=FRMDITCO&MTYPE=DISCHRG
## 5 https://dwr.state.co.us/SurfaceWater/data/detail_graph.aspx?ID=FRYTHOCO&MTYPE=DISCHRG
## 6 https://dwr.state.co.us/SurfaceWater/data/detail_graph.aspx?ID=ALATERCO&MTYPE=DISCHRG
As you can see, the data has to be cleansed to remove missing values, unnecessary data and changing the format to human readable format. Here is the cleansed data
df <- fromJSON("WaterQuality.json") %>% flatten(recursive = TRUE)
df[is.na(df)] <- "0"
df$amount <- as.numeric(df$amount)
df <- df %>% filter(county != "0", amount != 0)
df$dt <- as.POSIXct(df$date_time, format("%Y-%m-%dT%H:%M:%S"), tz = "MST")
df$tm <- format(df$dt, "%H:%M:%S")
df$dt <- as.character(date(df$dt))
filteredDF <- df %>% select(station_type, county, amount, date_time, dt, tm)
head(filteredDF)## station_type county amount date_time dt tm
## 1 Stream JACKSON 321.00 2019-10-30T05:45:00.000 2019-10-30 05:45:00
## 2 Stream DELTA 0.06 2019-12-29T21:15:00.000 2019-12-29 21:15:00
## 3 Stream PITKIN 26.60 2019-12-29T21:30:00.000 2019-12-29 21:30:00
## 4 Stream PUEBLO 41.90 2019-12-29T21:45:00.000 2019-12-29 21:45:00
## 5 Stream EAGLE 271.00 2019-12-29T21:30:00.000 2019-12-29 21:30:00
## 6 Stream DOUGLAS 14.10 2019-12-29T21:00:00.000 2019-12-29 21:00:00
Here is a plot showing the total amount of water dischared for each station type