diff --git a/02_Cleaning_scripts/WQ_GTMNERR.R b/02_Cleaning_scripts/WQ_GTMNERR.R
index b6e2dec..34ffe2d 100644
--- a/02_Cleaning_scripts/WQ_GTMNERR.R
+++ b/02_Cleaning_scripts/WQ_GTMNERR.R
@@ -73,9 +73,25 @@ which(is.na(WQ$long))
WQ[which(is.na(WQ$lat)),] # duplicates?? Remove for now; emailed Nikki
WQ <- WQ[-which(is.na(WQ$lat)),]
+# Create a separate dataframe with only station info, not the data (makes map
+# too heavy)
+WQ_locations <- WQ %>%
+ mutate(Year = year(SampleDate)) %>%
+ select(site_friendly, Year, site_acronym, lat, long, wbid, location) %>%
+ group_by(site_friendly, site_acronym, lat, long, wbid, location) %>%
+ summarize(maxYear = max(Year), minYear = min(Year))
+
+WQ_data_available <- WQ %>%
+ mutate(Year = year(SampleDate)) %>%
+ select(StationCode, Year, SampleType, ComponentShort, ComponentLong, site_friendly,
+ site_acronym, lat, long, wbid, location) %>%
+ distinct()
+
### 4. Save data ---------------------------------------------------------------
# Save it as an .Rdata (and .Rds?) file so it can be read into the Shiny app
save(WQ, file = "03_Data_for_app/WQ.RData")
-
saveRDS(WQ, "03_Data_for_app/WQ.Rds")
+
+save(WQ_locations, file = "03_Data_for_app/WQ_locations.RData")
+saveRDS(WQ_locations, "03_Data_for_app/WQ_locations.Rds")
diff --git a/03_Data_for_app/WQ_locations.RData b/03_Data_for_app/WQ_locations.RData
new file mode 100644
index 0000000..c2b902d
Binary files /dev/null and b/03_Data_for_app/WQ_locations.RData differ
diff --git a/03_Data_for_app/WQ_locations.Rds b/03_Data_for_app/WQ_locations.Rds
new file mode 100644
index 0000000..93e0406
Binary files /dev/null and b/03_Data_for_app/WQ_locations.Rds differ
diff --git a/app.R b/app.R
index 7c79520..de48352 100644
--- a/app.R
+++ b/app.R
@@ -72,11 +72,13 @@ HAB_data_locations <- HAB %>%
distinct() %>%
st_as_sf(coords = c("Longitude", "Latitude"), crs = 4326)
+#### WQ locations data ------------------------------------------------
+load("./03_Data_for_app/WQ_locations.RData")
+WQ_data_locations <- WQ_locations %>%
+ st_as_sf(coords = c("long", "lat"), crs = 4326)
+
#### WQ data ------------------------------------------------
load("./03_Data_for_app/WQ.RData")
-WQ_data_locations <- WQ %>%
- distinct() %>%
- st_as_sf(coords = c("long", "lat"), crs = 4326)
#### GTMNERR shapefile ------------------------------------------------
GTMNERR <- st_read("./03_Data_for_app/shapefiles_new/GTMNERR.shp")
@@ -178,8 +180,9 @@ server <- function(input, output) {
# group = "HAB") %>%
addMarkers(data = WQ_data_locations,
popup = ~paste("Station: ", site_friendly, "
",
- "Location: ", wbid,
- "Sample type: ", SampleType),
+ "Location: ", wbid, "
",
+ "Latest year of sampling: ", maxYear, "
%
# # Layers control (turning layers on and off)
addLayersControl(overlayGroups = c("Counties", "GTMNERR boundaries", "WQ"),