Many of my weekends this past summer were spent exploring the coast of New England, visiting all the states from Connecticut to Maine. In addition to seeing some beautiful coastal scenery and cool birds, being on the coast meant eating a ton of lobster. I came to love these delicious Decapods and now that landlocked in Ithaca for the foreseeable future, where lobsters are prohibitively expensive, I figured the next best thing to eating lobster was writing a blog post about them. Also, this provided a good excuse to play with the gganimate package.

I found data on annual lobster catch by state going back to 1950 on the NOAA website. In addition to the data on the American Lobster, NOAA provides catch statistics for three other lesser known species in the lower 48.

library(tidyverse)
library(sf)
library(rnaturalearth)
library(viridis)
library(hrbrthemes)
library(gganimate)
library(here)

I’ll start by loading and tidying up the data from NOAA. Unfortunately, there doesn’t seem to be an easy way to grab these data programatically, so I had to manually download files for each species.

cols <- c("year", "state", "species", "tons", "pounds", "value")
lobsters <- here("_source/data/lobster/") %>% 
  list.files("^lobster", full.names = TRUE) %>% 
  map_df(read_csv, skip = 5, col_names = cols) %>% 
  mutate(
    species = recode(species,
                     "LOBSTER, AMERICAN" = "American Lobster",
                     "LOBSTER, BANDED SPINY" = "Banded Spiny Lobster",
                     "LOBSTER, CALIFORNIA SPINY" = "California Spiny Lobster",
                     "LOBSTER, CARIBBEAN SPINY" = "Caribbean Spiny Lobster",
                     "LOBSTER, SLIPPER" = "Slipper Lobster"),
    state = recode(state,
                   "Florida East Coast" = "Florida",
                   "Florida West Coast" = "Florida")) %>% 
  group_by(year, state, species) %>% 
  summarise_all(funs(sum)) %>% 
  filter(state != "Hawaii") %>% 
  ungroup()

First, I’ll look at the temporal trend by species.

lobsters_trend <- lobsters %>% 
  group_by(year, species) %>% 
  select(-state) %>% 
  summarise_all(funs(sum))
ggplot(lobsters_trend, aes(year, tons / 1000)) +
  geom_line(aes(color = species), size = 1.15) +
  scale_color_brewer(NULL, palette = "Set1") +
  scale_y_comma("Catch (millions kg)") +
  scale_x_continuous("Year", breaks = seq(1950, 2010, by = 10)) +
  labs(title = "US commercial catch of lobster by species",
       caption = "Data: NOAA") +
  theme_ipsum_rc() +
  theme(legend.position = "bottom")

plot of chunk trend

Clearly the American Lobster is the most commercially important species in the US. There is a small Caribbean Spiny Lobster fishery, but the catch for the other two species is insignificant compared to the American Lobster. Next I’ll look at catch of American Lobster by state over time.

top_9_states <- lobsters %>% 
  filter(species == "American Lobster") %>% 
  group_by(state) %>% 
  select(-year, -species) %>% 
  summarize_all(funs(sum)) %>% 
  top_n(9, tons) %>% 
  arrange(desc(tons)) %>% 
  pull(state)
lobster_state <- lobsters %>% 
  filter(species == "American Lobster",
         state %in% top_9_states) %>% 
  mutate(state = factor(state, levels = top_9_states))
ggplot(lobster_state, aes(year, tons / 1000)) +
  geom_line(aes(color = state), size = 1.15) +
  scale_color_brewer(NULL, palette = "Set1") +
  scale_y_comma("Catch (millions kg)") +
  scale_x_continuous("Year", breaks = seq(1950, 2010, by = 10)) +
  labs(title = "US commercial catch of American Lobster",
       caption = "Data: NOAA") +
  theme_ipsum_rc() +
  theme(legend.position = "bottom")

plot of chunk states

Again, no surprise here, Maine is the biggest lobster producer in the US; however, it is interesting to note that it’s only since the mid-1980s that lobster production has really exploded in Maine, leaving all the other states behind.

Finally, I’ll show the spatial and temporal trend on an animated map. I’ll zoom in on the Northeastern US, since these are the only states producing American Lobsters and I’ll use a log scale since Maine is so dominant.

# state boundaries
states <- ne_states(iso_a2 = c("US", "CA"), returnclass = "sf") %>% 
  filter(!postal %in% c("AK", "HI")) %>% 
  select(country = iso_a2, state = name, state_code = postal, geometry)
# bring in lobster data
lobster_sf <- lobsters %>% 
  filter(species == "American Lobster") %>% 
  complete(state, year, fill = list(tons = 0, pounds = 0, value = 0)) %>% 
  select(-species) %>% 
  inner_join(states, ., by = "state")
# prepare log scale
rng <- ceiling(range(log10(lobster_sf$tons + 1)))
brk <- rng[1]:rng[2]
lbl <- c(0, bquote(10^1), bquote(10^2), bquote(10^3), 
         bquote(10^4), bquote(10^5))
# map
proj <- paste0("+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=37.5 +lon_0=-96",
               "+x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs")
g <- ggplot() + 
  geom_sf(data = states, fill = "grey80", color = "grey60") +
  geom_sf(data = lobster_sf,
          aes(fill = log10(tons + 1), frame = year)) +
  scale_fill_viridis("Annual Commercial Lobster Catch (metric tons)",
                     breaks = brk, labels = lbl,
                     guide = guide_colourbar(title.position = "top",
                                             title.hjust = 0.5)) +
  coord_sf(crs = proj, 
           xlim = c(553469.1, 2259794), 
           ylim = c(-259859.5, 1406546.0)) +
  labs(title = NULL, caption = "Data source: NOAA") +
  theme_minimal() +
  theme(legend.position = "bottom",
        legend.key.width = unit(0.15, "npc"),
        plot.title = element_text(hjust = 0.5))
# animate
gganimate(g, interval = .2)

Well, not that exciting really, but cool how easy gganimate is to use!