library(spData)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
library(sf)
## Linking to GEOS 3.8.1, GDAL 3.1.1, PROJ 6.3.1
library(hydrogeo)
data <- read.csv("PIPER.csv")
#data has the values for my piper plot in the proper format
pz <- piper(data)
plot(pz, main = "Collierville and Germantown Water Quality")
## [1] TRUE
legend("topright", data$Well.ID, pch = 1:7, col = 1:7)

#piper plot identifies the hydrochemical facies as mixed to magnesium bicarbonate type
WL <- read.csv("WL.csv")
#WL has the groundwater elevation for my wells in the Memphis Aquifer
plot(WL$Water_Level_Elevation_fasl)

WL %>% filter(Water_Level_Elevation_fasl > 300)
## Value_ID GWI_ID USGS_ID OWNER_ID Latitude_Decimal Longitude_Decimal
## 1 9 TN157_002374 Sh:M-057 Johnson-8 846827.6 288740.8
## 2 11 TN157_002382 0 Johnson-9 847611.1 288732.7
## 3 18 TN157_002136 0 502 869365.8 274850.2
## 4 22 TN157_002129 Sh:M-036 103 872175.7 278928.8
## GPS_GS_Elev_Fasl Aquifer Method Depth_to_Water_from_Measuring_Point
## 1 356.9847 Memphis AL 9
## 2 348.6453 Memphis AL 5
## 3 358.0035 Memphis AL 55
## 4 389.6792 Memphis AL 47
## Water_Level_Elevation_fasl
## 1 352.1517
## 2 345.9783
## 3 307.3335
## 4 345.2592
#All values above 300 were measured with AirLine, not reliable
PW <- st_read("gtown_cville_productionwells.shp")
## Reading layer `gtown_cville_productionwells' from data source `/Users/devinhainje/Desktop/R/gtown_cville_productionwells.shp' using driver `ESRI Shapefile'
## Simple feature collection with 32 features and 22 fields
## geometry type: POINT
## dimension: XY
## bbox: xmin: -89.80828 ymin: 35.02308 xmax: -89.66258 ymax: 35.08532
## geographic CRS: NAD83
#PW has the locations of production wells/ well fields
ggplot() + geom_point(data= PW, aes( x= LONGITUDE, y= LATITUDE))

cville <- st_read("cville.csv")
## Reading layer `cville' from data source `/Users/devinhainje/Desktop/R/cville.csv' using driver `CSV'
## Warning: no simple feature geometries present: returning a data.frame or tbl_df
#cville has the available geochemical data over the last ~20 years
ggplot(cville, aes(x=Year, y=pH, color = Owner)) + geom_point() + ggtitle("pH Data")

ggplot(cville, aes(x=Year, y=Cond, color = Owner)) + geom_point() + ggtitle("Specific Conductivity Data")

ggplot(cville, aes(x=Year, y=Alk., color = Owner)) + geom_point() + ggtitle("Alkalinity Data")

#plots of field measured values, separated by Owner (Germantown or Collierville)
#some clear trends are visible, pH higher and alkalinity are higher in Germantown
#Box plots or bar graphs would not accurately portray the data because each point is at a different location
cville$Cl.<- as.numeric(cville$Cl.)
cville$Na <- as.numeric(cville$Na)
ggplot(cville, aes(x= Cl., y= Na)) + geom_point() + ggtitle("Cl vs. Na data")
## Warning: Removed 13 rows containing missing values (geom_point).

#Cl vs. Na trends show the precipitation/dissolution of halite (NaCl) in the groundwater
cville$Ca <- as.numeric(cville$Ca)
cville$Mg <- as.numeric(cville$Mg)
ggplot(cville, aes(x= Mg, y= Ca)) +
geom_point() + ggtitle("Mg vs Ca data")
## Warning: Removed 13 rows containing missing values (geom_point).

#Mg vs. Ca trends show the precipitation/dissolution of carbonate minerals in groundwater