LimnoDataScience / plume_bloom_drivers

Using classified raster images and meteo drivers to try to better understand what is causing sediment plumes and blooms in Lake Superior
1 stars 1 forks source link

Summarize climate by watershed #8

Closed lindsayplatt closed 1 year ago

lindsayplatt commented 1 year ago

Fixes #5. Switches to creating daily timeseries of mean temperature (deg C) and total precipitation (mm) by watersheds rather than individual points. For now, we are using 3 USGS river outlets for the Nemadji, Bois Brule, and Siskiwit rivers and their associated HUC10 as the watershed polygons.

First, I used nhdplusTools with the 3 USGS river gage values to identify the 8-digit hydrologic units (HUC08) associated with those outlets. There was only 1 HUC08 for all 3. Then, I used the HUC08 shape to query nhdplusTools for 10-digit HUCs (HUC10) within the single HUC08 (shown in grey below). From there, I filtered to the HUC10s that actually contain the outlet point (shown in dark grey below). It is unclear to me whether I should group more of the HUC10s together to create the watershed values (especially for the Nemadji site (western site). The thick, large outline is that of the Lake Superior watershed that fit within our AOI.

image

Next, I filtered our grid across the AOI to just those that had one of the 3 HUC10s within them. Those 37 cells are denoted with the thick outlines.

image

Then I took the daily values of temperature, grouped by the HUC, and calculated the mean of all the cells for that HUC. For precipitation, I am totaling the daily values from all grid cells within a HUC. To do this as accurately as possible, I multiplied each grid cell's precipitation value by the fraction of the cell overlapping the HUC so that places where a grid cell only barely overlaps with the HUC are not getting more precipitation counted into the total than they should. The figure below shows the fraction values used to adjust the precipitation values for each HUC.

image

The summary figures generated by the pipeline for the daily precipitation and mean temperature are now shown per HUC. Here are the two outputs p4_prism_summary_timeseries and p4_prism_summary_boxes:

image

image

Expand this to see the code to create these plots ```r library(sf) library(ggplot2) library(targets) crs_to_map <- st_crs(tar_read(p2_lake_superior_watershed_dissolved)) # Identifying watersheds (HUC10s) to use for each outlet # First, get all the HUC10s (which is not a step saved separately as a target) huc10_sf <- nhdplusTools::get_huc(AOI = tar_read(p1_huc08_nwis_sites), type='huc10') %>% # Remove the actual lake itself st_filter(tar_read(p1_huc08_nwis_sites), .predicate = st_within) %>% st_transform(crs=crs_to_map) ggplot() + geom_sf(data = huc10_sf) + geom_sf(data = st_transform(tar_read(p1_huc10_nwis_sites), crs = crs_to_map), fill="darkgrey", lwd=0.75) + geom_sf(data = tar_read(p2_lake_superior_watershed_dissolved), fill=NA, lwd=1) + geom_sf(data = tar_read(p1_nwis_sites_sf), color = "red") + theme_bw() + ggtitle('Sites and HUC10 watersheds chosen') # Creating grids and determining which to use ggplot() + geom_sf(data = tar_read(p2_lake_superior_watershed_dissolved), fill=NA, lwd=1) + geom_sf(data = st_transform(tar_read(p1_huc10_nwis_sites), crs = crs_to_map), fill="grey", color=NA) + geom_sf(data = tar_read(p2_lake_superior_watershed_grid_all), fill=NA) + geom_sf(data = tar_read(p2_lake_superior_watershed_grid_sf), aes(color = huc), fill=NA, lwd=1) + theme(panel.background = element_rect(fill='white')) + coord_sf() + ggtitle('Grid cells over Lake Superior AOI', subtitle = 'Cells that overlap with the 3 HUCs are highlighted') # Calculating precip per HUC ggplot() + geom_sf(data = tar_read(p2_lake_superior_watershed_grid_sf), alpha = 0.5, lwd=1, aes(fill=huc_frac, color=huc)) + geom_sf(data = st_transform(tar_read(p1_huc10_nwis_sites), crs=st_crs(tar_read(p2_lake_superior_watershed_dissolved))), aes(group = huc10), fill=NA, color="black", lwd=2) + scico::scale_fill_scico(begin=0.25) + theme_bw() + ggtitle("Fraction of cell overlapping with the watershed", subtitle="Fraction x Precip of each grid cell = amount of precip added to get HUC total") ```
lindsayplatt commented 1 year ago

Merging with the idea that improvements can be made in future PRs.