Here And Now: These Maps Show How Climate Change Has Already Transformed The Earth

Data and R code used to make the maps and animation in this Apr. 22, 2019 BuzzFeed News post on the current reality of climate change. Supporting files are in this GitHub repository.

Animation showing trend in area of Arctic sea ice

Code to create an animation of the National Snow and Ice Data Center’s daily Arctic Sea Ice Index. To make the animated GIF, you will need to install ImageMagick.

# load additional required packages
library(readr)
library(ggplot2)
library(lubridate)

# load and process data
sea_ice <- read_csv("ftp://sidads.colorado.edu/DATASETS/NOAA/G02135/north/daily/data/N_seaice_extent_daily_v3.0.csv") %>%
  slice(-1) %>%
  select(1:5) %>%
  mutate(Date = ymd(paste0(Year,Month,Day)),
         Date2 = ymd(paste0("2018",Month,Day)),
         Year = as.integer(Year),
         Extent = as.double(Extent)) %>%
  filter(Date >= "1979-01-01")

# Loop to make one frame for each year
for (y in c(1980:2019)) {
  tmp <- sea_ice %>%
    filter(Year < y)
  tmp2 <- sea_ice %>%
    filter(Year == y)
  plot <- ggplot(tmp, aes(x = Date2, y = Extent, group = Year)) +
    geom_line(color = "#cccccc") +
    theme_minimal(base_size = 18, base_family = "BasierSquare-SemiBold") +
    labs(x= "", y = "Ice area (million square km)") +
    scale_x_date(date_labels = "%b",
                 date_breaks = "month",
                 limits = c(as.Date("2018-01-01"), as.Date("2018-12-31"))) +
    scale_y_continuous(limits=c(0,18)) +
    theme(panel.grid.minor = element_blank(),
          legend.position = c(0.2,0.2),
          plot.title = element_text(size = 30, color = "#08519c")) +
    geom_line(data = tmp2, color = "#08519c", size = 1) + 
    ggtitle(y)
  ggsave(paste0("png/",y,"_sea_ice.png"), width = 9, height = 5, units = "in",
                dpi = 300)
}

# make GIF with ImageMagick (note, on Windows use shell function instead of system)
system("convert png/*.png -set delay 20 gif/seaice.gif")

# increase the delay on the final frame
system("convert gif/seaice.gif \\( +clone -set delay 300 \\) +swap +delete  gif/seaice.gif")