~hrbrmstr/foliage

aa86b79c4ffe64841a3a145d0c55a6d2af14720f — boB Rudis 11 months ago 9dc4e0f
2019
2 files changed, 9 insertions(+), 10 deletions(-)

M foliage-2019.R
M foliage.R
M foliage-2019.R => foliage-2019.R +3 -4
@@ 28,7 28,6 @@ st_crs(states_sf) <- 4326
# I ran into hiccups using coord_sf() to do this, so we convert it to Albers here
states_sf <- st_transform(states_sf, 5070)


# next we read in the states
counties_sf <- read_sf(file.path(root, "data", "us.min.json"), "counties", stringsAsFactors = FALSE)
st_crs(counties_sf) <- 4326


@@ 54,8 53,8 @@ gather(foliage_sf, week, value, -id, -geometry) %>%
  filter(week != "rate1") %>%
  mutate(week = factor(week,
                       levels=unique(week),
                       labels=format(seq(as.Date("2017-08-26"),
                                         as.Date("2017-11-11"), "1 week"),
                       labels=format(seq(as.Date("2019-09-08"),
                                         as.Date("2019-11-30"), "1 week"),
                                     "%b %d"))) -> foliage_sf

# now we make a ggplot object for each week and save it out to a png


@@ 91,4 90,4 @@ walk(1:nlevels(foliage_sf$week), ~{
})

# animate the foliage
image_animate(frames, 1)
image_animate(frames, 1) %>% image_write("~/Desktop/f.gif")

M foliage.R => foliage.R +6 -6
@@ 29,7 29,6 @@ st_crs(states_sf) <- 4326
# I ran into hiccups using coord_sf() to do this, so we convert it to Albers here
states_sf <- st_transform(states_sf, 5070)


# next we read in the states
counties_sf <- read_sf(file.path(root, "data", "us.json"), "counties", stringsAsFactors = FALSE)
st_crs(counties_sf) <- 4326


@@ 71,14 70,15 @@ walk(1:nlevels(foliage_sf$week), ~{
    viridis::scale_fill_viridis(
      name=NULL,
      discrete = TRUE,
      labels=c("No Change", "Minimal", "Patchy", "Partial", "Near Peak", "Peak", "Past Peak"),
      drop=FALSE
      labels = c("No Change", "Minimal", "Patchy", "Partial",
                 "Near Peak", "Peak", "Past Peak"),
      drop = FALSE
    ) +
    labs(title=sprintf("Foliage: %s ", unique(xdf$week))) +
    ggthemes::theme_map() +
    theme(panel.grid=element_line(color="#00000000")) +
    theme(panel.grid.major=element_line(color="#00000000")) +
    theme(legend.position="right") -> gg
    theme(panel.grid = element_line(color = "#00000000")) +
    theme(panel.grid.major = element_line(color = "#00000000")) +
    theme(legend.position = "right") -> gg

  print(gg)