library(dplyr)
library(ggplot2)
library(reshape2)
library(lubridate)
library(tidyr)
## Warning: package 'tidyr' was built under R version 3.2.2
library(ggmap)
library(RODBC)
## Warning: package 'RODBC' was built under R version 3.2.2
setwd("\\\\psf/Home/Dropbox/")
#setwd("c:/Users/Katrina/Dropbox/")
# User: fill in location, date(s), file names; report will get relevant data
location = 'UPLUPL'
sample_date = 'August 7, 2015'
DeployID = "20150807"
VerticalSurveyID = "20150807"
#load Deployment table exported from Access
oxy1 <- read.csv(
"MysticDB/Conversion/sonde/testing_20150807/Deployments_export_test.csv",
strip.white=TRUE, header = TRUE, as.is=TRUE)
# parse date and specify time zone
oxy2 <- oxy1 %>%
mutate(Datetime = mdy_hm(Datetime, tz="UTC")) %>%
mutate(Datetime = with_tz(Datetime, tzone="US/Eastern"))
#filter for desired parameters
oxy2 <- oxy2 %>%
filter(DeploymentID == DeployID) %>%
filter(CharacteristicID == "DO" | CharacteristicID == "DO_SAT" |
CharacteristicID == "CHLA" | CharacteristicID == "SPCOND" |
CharacteristicID == "TEMP_WATER" | CharacteristicID == "DEPTH")
#load Surveys table of vertical profiles exported from Access
oxyvertacc <- read.csv(
"MysticDB/Conversion/sonde/testing_20150807/Survey_export_test.csv",
strip.white=TRUE, header = TRUE, as.is=TRUE)
# parse date and filter for id
oxyvertacc2 <- oxyvertacc %>%
filter(SurveyID == VerticalSurveyID) %>%
mutate(Datetime = mdy_hms(Datetime, tz="UTC")) %>% #need time to the sec to uniquely id
mutate(Datetime = with_tz(Datetime, tzone="US/Eastern"))
oxyvertacc2 <- unique( oxyvertacc2[ , 1:8 ]) #handheld creates duplicate records; remove
On August 7, 2015, the Mystic River Watershed Association deployed a YSI EXO2 water quality sonde to monitor several water quality parameters.
g <- ggplot(oxy2, aes(Datetime, ResultValue))
g + geom_line() + facet_wrap( ~ CharacteristicID, ncol= 2, scale = "free_y") +theme_bw() + theme(axis.text.x = element_text(angle = 45, hjust = 1))
Vertical profile data from pre-event sampling, ~4pm, August 7.
# Shape Access data and plot
# spread data for scatterplots
oxyvertplot <- oxyvertacc2 %>%
#spread(CharacteristicID, ResultValue)
dcast(Datetime ~ CharacteristicID, value.var = "ResultValue")
oxyvertplot <- left_join(oxyvertacc2, oxyvertplot) %>%
filter(CharacteristicID == "CHLA" | CharacteristicID == "DO" |
CharacteristicID == "DO_SAT" |
CharacteristicID == "SPCOND" |CharacteristicID == "DEPTH"
|CharacteristicID == "TEMP_WATER")
g <- ggplot(arrange(oxyvertplot, DEPTH), aes(ResultValue, DEPTH))
g + facet_wrap( ~ CharacteristicID, ncol= 3, scale = "free_x") + theme_bw() +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
scale_y_reverse() + ylab("Depth (m)") +
geom_path(aes(color = DEPTH), size = 1) +
scale_color_gradient(low = "gray94", high = "gray37") +
guides(color = guide_colorbar(reverse=T)) + geom_point()
map <- get_map(location=c(lon=mean(range(c(-71.150185, -71.142576))), lat=mean(range(42.446026, 42.439893))), zoom=15, maptype="roadmap")
site <- data.frame('MAR003', 42.443936, -71.145582)
col_headings <- c('loc','Latitude','Longitude')
names(site) <- col_headings
ggmap(map, darken=c(0.25, "white"), extent="device") +
geom_point(aes(x = Longitude, y = Latitude), data = site,
alpha = .5, color="red", size = 7) +
annotate('text', label = 'MAR003')