tbep-tech / State-of-the-Bay

State of the Bay content including figures and text for website
1 stars 0 forks source link

Bay metro area population estimates #19

Closed fawda123 closed 2 years ago

fawda123 commented 2 years ago

@esherwoo77 I was able to pull annual ACS data from 2005 - 2019, then supplement with decennial surveys for 1990, 2000 (Man., Hills., Pinn. counties). Check out the result here (bottom plot): https://tbep-tech.github.io/State-of-the-Bay/total-nitrogen-loading

Code for getting the population data is here: https://github.com/tbep-tech/State-of-the-Bay/blob/master/R/dat_proc.R

Happy to take suggestions or add any historic data you might have.

esherwoo77 commented 2 years ago

@fawda123 : I was able to track down my old code and datasets for reproducing the pop vs. chl-a figure. The R Project file and datasets are here if you'd like to get at the 'source': G:\Ed\GIT_Projects\tb_loading_data (don't laugh these were my first OS products after the OSS Workshop).

Also attaching the datasets, and the simple R script below for recreating the plot. I'm sure you can leverage the tbeptools package to get at some of these data by now. Some of the historic US census bureau data are likely interpolations between estimates from the census and/or TBRPC, like we've previously discussed.

tb_total_tn_hydro_loads_jei09222017.csv uscb_pop_estimates_tb_metro.csv TBEP_DM_Means_1974-2016.csv

`library(tidyverse)

dm_avg <- read_csv(file = "../TBEP_DM_Means_1974-2016.csv") pop <- read_csv(file = "../uscb_pop_estimates_tb_metro.csv") hydro <- read_csv(file = "../tb_total_tn_hydro_loads_jei09222017.csv")

tb_avg <- dm_avg %>% group_by(year) %>% summarise(tbavg = mean(chla_dm_avg))

tbdata <- left_join(hydro, pop, by = "year") cols <- c("Hydrologically Normalized TN Loads"="blue", "Tampa Bay Metropolitan Area Population"="black") p <- ggplot(data=tbdata, aes(x=year)) p <- p + geom_line(aes(y=tb_total_hydro_tn, colour = "Hydrologically Normalized TN Loads")) p <- p + geom_line(aes(y=USCB_POP_EST_TB_Metro/650, colour = "Tampa Bay Metropolitan Area Population")) p <- p + scale_y_continuous(sec.axis = sec_axis(~.*0.00065, name = "Tampa Bay Population (in millions)")) p <- p + theme(legend.position = c(0.2, 0.95), legend.background = element_rect(fill=NA)) p <- p + scale_colour_manual(name="", values=cols, labels=c("Hydrologically Normalized TN Loads", "Tampa Bay Metropolitan Area Population")) p <- p + labs(y = "Total Hydrologically Normalized TN Load to Tampa Bay (tons/year)") p <- p + labs(x = "Year") p`

esherwoo77 commented 2 years ago

Attached is the decadal summary that's in the 2017 RA Update and that I produced in Excel .

TNLoad_per_Capita_1976-2016_DRAFTLOADS_06022017.xlsx

fawda123 commented 2 years ago

Thanks @esherwoo77, I'm curious if you think my plot is an improvement or we should stick with the old one. I'm not married to either. image

esherwoo77 commented 2 years ago

The bottom plot is hard to interpret trends, based on what we've developed and presented in the past. Keeping the upper two, and simplifying/summarizing the bottom plot would be my preference.

fawda123 commented 2 years ago

Redid the plot to create an output similar to your original code, also supplemented pop data back to 1985: image