Maps

# df with soy deforestation per muni since 2008
munis_to_plot <- brazil_soy %>% 
  filter(YEAR >= 2008) %>%
  group_by(GEOCODE) %>%
  summarise(SOY_DEFORESTATION_KHA = sum(SOY_DEF_5_YEAR_HA, na.rm = T) / 1000) %>%
  ungroup() %>% 
  mutate(GEOCODE = as.character(GEOCODE)) %>%
  inner_join(munis, ., by = "GEOCODE")

# Plot
ggplot() +
  geom_sf(data = brazil, 
          fill = trase_country_background,
          col = trase_map_border) +
  geom_sf(data = munis_to_plot,
          aes(fill = SOY_DEFORESTATION_KHA), 
          col = NA) +
  geom_sf(data = st_simplify(biomes %>% filter(name == "Cerrado"), dTolerance = 0.1), 
          fill = NA, 
          linetype = "longdash",
          aes(colour = "CERRADO"),
          show.legend = "line") +
  theme_trase() +
  theme(legend.spacing.y = unit(0.2, "cm")) +
  scale_fill_viridis(option="magma",
                     name = bquote('DEFORESTATION (HA)'),
                     direction = -1,
                     label = unit_format(unit = "K")) +
  coord_sf(datum = NA) +
  scale_colour_manual(values = c("CERRADO" = trase_map_border)) +
  labs(title = "Titles are in black",
       subtitle = "Subtitles in grey") +
  guides(col=guide_legend(title=NULL),
         fill = guide_colourbar(ticks = FALSE))

Graphs