knitr::opts_chunk$set(echo = TRUE, message = FALSE)
knitr::opts_knit$set(root.dir = rprojroot::find_rstudio_root_file())
library(tidyverse)
library(readxl)
library(cvpiaHabitat)

Rearing Pools

lengths_table <- read_excel('data-raw/floodplain/CVPIA_FloodplainAreas.xlsx',
                            sheet = 'MetaData',
                            col_types = c('text', 'text', 'text', 'text', rep('numeric', 17),
                                          'text', 'numeric', 'text'),
                            na = 'na')

pools_perc <- read_csv('data-raw/instream/pools/pools.csv', col_types = 'cnc') %>%
  select(-FW_QAQC)

mean_pools_perc <- filter(pools_perc, watershed != 'Feather River') %>%
  pull(percent_pools) %>% mean(na.rm = TRUE)

pools_perc
wss <- cvpiaData::watershed_ordering$watershed

pools <- lengths_table %>%
  filter(watershed %in% wss) %>%
  mutate(SR_prop_length = SR_rearing_length_mi/FR_rearing_length_mi,
         ST_prop_length = ST_rearing_length_mi/FR_rearing_length_mi,
         FR_channel_area = FR_channel_area_of_length_modeled_acres,
         SR_channel_area = FR_channel_area * SR_prop_length,
         ST_channel_area = FR_channel_area * ST_prop_length) %>%
  select(watershed, FR_channel_area, SR_channel_area, ST_channel_area) %>%
  left_join(pools_perc) %>%
  mutate(percent_pools = replace(percent_pools, is.na(percent_pools), mean_pools_perc),
         SR_pools_sq_meters = SR_channel_area * percent_pools/100 * 4046.86,
         ST_pools_sq_meters = ST_channel_area * percent_pools/100 * 4046.86) %>%
  select(watershed, SR_pools_sq_meters, ST_pools_sq_meters) %>%
  left_join(cvpiaData::watershed_ordering) %>%
  arrange(order) %>%
  select(-order)

# put combinded values of upper sac + upper mid sac in upper sac
# upper sac + upper mid sac 6174 acres, from mark gard

pools_upper_sac <- 6174 * 7.2/100 * 4046.86

pools[pools$watershed == 'Upper Sacramento River', c('SR_pools_sq_meters', 'ST_pools_sq_meters')] <- c(pools_upper_sac, pools_upper_sac)

# use_data(pools, overwrite = TRUE)
pools


FlowWest/cvpiaHabitat documentation built on Oct. 27, 2020, 2:09 p.m.