State Restrictions on SNAP Map Code

Here is the R code I used to make up this map for those who want to play around with this at home.

State Restrictions on SNAP in 2026 [Expires December 1 2026]

library(tidyverse)
library(tigris)
library(rvest)
library(ggtext)
library(httr)

session <- session("https://www.fns.usda.gov/snap/waivers/foodrestriction",
                   user_agent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36"))

sh <- read_html(session) %>% html_table() %>% .[[1]]

usst <- states(cb=T, resolution = '20m') %>% shift_geometry()

sh %>%
  left_join(usst, ., join_by(NAME == `State`)) %>%
  ggplot() + geom_sf(aes(fill=`Summary of Request`), color='white', linewidth=0.5) +
  scale_fill_manual(values=RColorBrewer::brewer.pal(11, 'Paired'),
                    labels=\(x) str_wrap(x, width=40)) +
  theme_void() +
  coord_sf(expand = F, crs = 5070) +
  labs(
    title = str_c('<span style="color: ',RColorBrewer::brewer.pal(8, 'Blues')[8],'; font-size: 45pt;">State Restrictions on SNAP</span>'),
    subtitle = 'Restrictions on unhealthy food purchases using SNAP going into in effect in 2026.',
    tag = paste(
      "Andy Arthur,", format(Sys.Date(), format = "%-m/%-d/%y"), "<br />",
      "Source: fns.usda.gov/snap/waivers/foodrestriction"),
  ) +
  theme_void() +
  theme(
    text = element_text(family = "Roboto Condensed", size = 14),
    plot.title = element_textbox(hjust = 0.5, face = "bold", size = 28, margin = margin(0, 0, 1, 0)),
    plot.subtitle = element_textbox(hjust = 0.5, face = "italic", size = 14, margin = margin(0, 0, 10, 0)),
    plot.background = element_rect(fill = "beige", color = NA),
    plot.tag = element_textbox(size = 10, hjust = 1, color = "#555555", maxheight = 0, halign = 1),
    plot.caption = element_text(size = 14, color = "#555555"),
    plot.margin = unit(c(0,1,0,0), "cm"),
    plot.tag.position = c(1, 0.03),
    strip.text = element_text(face='bold', size=16),
    legend.key.height = unit(1, "cm"),
    legend.key.width = unit(1, "cm"),
    legend.direction = "horizontal",
    legend.spacing = unit(3, 'cm'),
    legend.margin = margin(0, 0, 0, 0),
    legend.position.inside = c(0,0)
  ) +
  guides(fill = guide_legend(ncol=1, title = '', override.aes = list(width=1)))

Leave a Reply

Your email address will not be published. Required fields are marked *