---
title: "Clipping rivers from LA tract map"
author: "Jenna"
date: "October 1, 2020"
output: word_document
---

```{r setup, include=FALSE}
library(rmarkdown)
knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE)

library(here)
source(here("sandbox/jenna/libraries jenna.R"))
```

```{r}
tracts.la <- sf::st_read(here("inputs/tl_2010_22_tract10/tl_2010_22_tract10.shp"))
```
```{r}

totPopRaw <- get_acs(geography = "county",
                       year = 2018,
                       variables = c("DP05_0001E"), 
                       state = c("LA"),
                       survey = "acs5")
popRank <- totPopRaw %>%
  filter(estimate >= 100000) 
```

```{r}
tracts.la %>% 
  mutate(GEOID5 = str_sub(GEOID10,1,5)) %>%
  left_join(popRank, by= c("GEOID5" = "GEOID")) %>%
  ggplot() +
  geom_sf(aes(fill = estimate), color = "gray70", size = .05)+
  themeDC_map() +
  # scale_color_brewer(palette =  "Spectral") +
  # scale_fill_brewer(palette = "Spectral", direction = 1,  na.value = "gray70") +
  scale_fill_viridis_c() +
  coord_sf(datum = NA) +
  theme(legend.position = "right",
        plot.title=element_text(size=10, hjust=0.5, vjust=-1, family = "Asap", color ="#002F44"),
        plot.subtitle=element_text(size=9, hjust=0.5, face="bold", color="#002F44", family = "Asap"),
        plot.caption =element_text(size=9, hjust=0, face="italic", color = "#002F44", family = "Asap"),
        legend.text=element_text(size=9, family = "Asap", color = "#002F44"),
        legend.title= element_blank()) +
  labs(title = "Parishes with population 50,000+",  
       subtitle  =  "Louisiana, 2018 ACS 5") 
```

```{r}
popRank
```
109:   
FID = 724 (Intracoastal waterway through Houma)   

079:   
FID = 96 (Red River through Alexandria)  

073:  
FID = 38 (Ouachita River through Monroe)   

071:   
FID = 507, 286, 320 (MS River through New Orleans)   

051:   
FID = 40 (MS River through Kenner/Metairie)  

033:   
FID = 42 (MS River through Baton Rouge)   

019:   
FID = 96, 509, 374, 148, 504 (Calcasieu River + lakes through Lake Charles)   

015:   
FID = 67, 152 (Red River through Shreveport)

Parishes without water bodies cutting through areas of dense population
105, 103, 063, 055, 017, 005   

```{r}
tracts.la.clipped <- sf::st_read(here("inputs/LA tracts clipped rivers parish pop over 100k/LA tracts clipped rivers parish pop over 100k.shp")) 

tracts.la.clipped%>%
  ggplot() +
  geom_sf(fill = "lightblue", color = "gray70", size = .05)+
  themeDC_map()
```

