Skip to content

Instantly share code, notes, and snippets.

@pecard
Created June 12, 2020 11:32
Show Gist options
  • Save pecard/4f543514deee2a810abf76cb549cf650 to your computer and use it in GitHub Desktop.
Save pecard/4f543514deee2a810abf76cb549cf650 to your computer and use it in GitHub Desktop.
gnb forest loss with gfc v1.7
library(tidyverse)
library(lubridate)
library(forcats)
library(janitor)
library(ggplot2)
library(ggthemr)
ggthemr('grape')
# Read Tables ----
refs <- read_csv('path to reference wdpa csv file') %>%
clean_names() %>%
select(id = system_index, name, wdpaid)
gfc <- read_csv('path to reference forest loss csv file') %>%
clean_names() %>%
mutate(area = (loss * 900) / 10000) %>%
left_join(refs, by = c('wdpaid' = 'wdpaid'))
labs <- c('Cufada', 'Cantanhez', 'Urok', 'Orango'
,'PNTC', 'PNMJVP')
gfc %>%
filter(wdpaid %in% c(33048, # Cufada
33049, # Cantanhez
342655, # Urok
33047, # Orango
555626105, # PNTC
317052 # PNMJVP
)
) %>%
ggplot() +
geom_bar(aes(x=as.factor(year), y=area, fill = name), stat = 'identity') +
scale_fill_discrete('Protected Area', labels = labs) +
scale_x_discrete(breaks = seq(2001, 2019, 3)) +
theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5),
legend.position = 'right') +
labs(x='year', y='Loss (ha)/year')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment