Browse Source

changed mind

master
boB Rudis 4 years ago
parent
commit
e18bd6352a
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 125
      2019-11-20-rural.R
  2. BIN
      data/NASSAgcensusDownload2017.xlsx
  3. BIN
      data/farm-internet-history.rds

125
2019-11-20-rural.R

@ -1,85 +1,104 @@
library(sf)
library(readxl)
library(tigris)
library(statebins)
library(geofacet)
library(albersusa)
library(hrbrthemes)
library(tidyverse)
farms <- read_excel(here::here("data/Ag_Census_Map_data_07172015.xlsx"), sheet = "Farms", col_names = TRUE)
farms_2012 <- read_excel(here::here("data/Ag_Census_Map_data_07172015.xlsx"), sheet = "Farms", col_names = TRUE)
farms_2017 <- read_excel(here::here("data/NASSAgcensusDownload2017.xlsx"), sheet = "Farms", col_names = TRUE)
ffactor <- c("Less than 250", "250 - 499", "500 - 749", "750 - 999", "1,000 or more")
counties_sf() %>%
mutate(fips = as.character(fips)) %>%
left_join(
select(farms, fips = FIPSTEXT, range = y12_M249_classRange, ct = y12_M249_valueNumeric),
select(
farms_2012,
fips = FIPSTEXT,
range = y12_M249_classRange,
ct = y12_M249_valueNumeric
),
by = "fips"
) %>%
mutate(range = factor(range, ffactor)) -> farms_df
mutate(
year = "2012",
range = factor(range, ffactor)
) -> y2012
as_tibble(farms_df) %>%
mutate(state = as.character(state)) %>%
count(state, wt=ct) -> farm_counts
counties_sf() %>%
mutate(fips = as.character(fips)) %>%
left_join(
select(
farms_2017,
fips = FIPSTEXT,
range = y17_M001_classRange,
ct = y17_M001_valueNumeric
),
by = "fips"
) %>%
mutate(
year = "2017",
range = factor(range, ffactor)
) -> y2017
ggplot() +
ggalt::geom_bkde(
data = farms_df, aes(ct),
color = "#006d2c", fill = alpha("#006d2c", 3/4)
select(y2017, fips, year, range, ct) %>%
ggplot() +
geom_sf(aes(fill = range), color = "#b2b2b2", size = 0.1) +
scale_fill_brewer(
name = "# Farms", palette = "Greens", na.value = "white", labels = ffactor, breaks = ffactor
) +
scale_x_comma() +
coord_sf(crs = albersusa::us_laea_proj, datum = NA) +
labs(
x = NULL, y = "Density",
title = "Farms-per-County Distribution"
x = NULL, y = NULL,
title = "Down On The Farm: County-level Census of Agriculture Farms-per-County",
subtitle = "While the USDA does track some 'urban farms' most of the farmland is, indeed, rural.",
caption = "Data: USDA <www.nass.usda.gov/Publications/AgCensus>; {tigris}\nhttps://git.rud.is/hrbrmstr/y2019-30daymapchallenge • #30DayMapChallenge"
) +
theme_ipsum_es(grid="XY")
theme_ipsum_es(grid="") +
theme(legend.position = c(0.985, 0.5))
ggplot() +
ggalt::geom_bkde(
data = farm_counts, aes(n),
color = "#006d2c", fill = alpha("#006d2c", 3/4)
) +
scale_x_comma() +
labs(
x = NULL, y = "Density",
title = "Farms-per-State Distribution"
) +
theme_ipsum_es(grid="XY")
select(y2017, fips, y2017=ct) %>%
left_join(
as_tibble(y2012) %>%
select(fips, y2012=ct)
) %>%
mutate(diff = y2017-y2012) -> decline
ggplot(farm_counts) +
geom_statebins(
aes(state = state, fill = n), family = font_es, size = 5
ggplot(decline) +
geom_sf(aes(fill = diff), color = "#b2b2b2", size = 0.1) +
scale_fill_distiller(
name = "Farms delta", palette = "BrBG", direction = 1, na.value = "white"
) +
scale_fill_viridis_c(
name = "# Farms", direction = -1, label = scales::comma
) +
coord_fixed() +
guides(fill = guide_colourbar(title.position = "top")) +
coord_sf(crs = albersusa::us_laea_proj, datum = NA) +
labs(
x = NULL, y = NULL,
title = "Farms",
subtitle = "farms",
caption = "Farms"
title = "Change in County Farm Counts 2012 - 2017",
subtitle = "~63% of counties saw a decline in the number of farms since the 2012 USDA Ag Census",
caption = "Data: USDA <www.nass.usda.gov/Publications/AgCensus>; {tigris}\nhttps://git.rud.is/hrbrmstr/y2019-30daymapchallenge • #30DayMapChallenge"
) +
theme_ipsum_es(grid="") +
theme(axis.text = element_blank()) +
theme(legend.position = c(0, 0.9)) +
theme(legend.justification = "left") +
theme(legend.direction = "horizontal") +
theme(legend.key.width = unit(2.75, "lines"))
theme(legend.position = c(0.985, 0.5))
ggplot() +
geom_sf(data = farms_df, aes(fill = range), color = "#b2b2b2", size = 0.1) +
scale_fill_brewer(
name = "# Farms", palette = "Greens", na.value = "white", labels = ffactor, breaks = ffactor
) +
coord_sf(crs = albersusa::us_laea_proj, datum = NA) +
farm_internet <- readRDS(here::here("data/farm-internet-history.rds"))
ggplot(farm_internet) +
geom_segment(aes(year, pct, xend=year, yend=0), color = "#66bd63") +
scale_x_date(breaks = range(farm_internet$year), labels = c("1997", "2019")) +
scale_y_percent(limits = c(0, 1)) +
facet_geo(~state) +
labs(
x = NULL, y = NULL,
title = "Down On The Farm: County-level Census of Agriculture Farms-per-County",
subtitle = "While the USDA does track some 'urban farms' most of the farmland is, indeed, rural.",
caption = "Data: USDA <www.nass.usda.gov/Publications/AgCensus/2012/Online_Resources/Ag_Census_Web_Maps/Data_download/index.php>; {tigris}\nhttps://git.rud.is/hrbrmstr/y2019-30daymapchallenge • #30DayMapChallenge"
title = "State-level Farms with Internet Access % (1997-2019)",
subtitle = "I'll admit to being optimistic that the current % was so high across the board",
caption = "Data: USDA <usda.library.cornell.edu/concern/publications/h128nd689>; {geofacet}\nhttps://git.rud.is/hrbrmstr/y2019-30daymapchallenge • #30DayMapChallenge"
) +
theme_ipsum_es(grid="") +
theme(legend.position = c(0.985, 0.5))
theme_ipsum_es(
grid="Y", strip_text_family = font_es_bold,
strip_text_size = 9, axis_text_size = 9
) +
theme(axis.text.x = element_text(hjust = c(0, 1))) +
theme(panel.spacing = unit(0.25, "lines"))

BIN
data/NASSAgcensusDownload2017.xlsx

Binary file not shown.

BIN
data/farm-internet-history.rds

Binary file not shown.
Loading…
Cancel
Save