Skip to content

Instantly share code, notes, and snippets.

@lsaravia
Last active January 5, 2020 18:12
Show Gist options
  • Save lsaravia/ef98f5e003b852a931324f46500de783 to your computer and use it in GitHub Desktop.
Save lsaravia/ef98f5e003b852a931324f46500de783 to your computer and use it in GitHub Desktop.
Minimal analysis of Australian fires (as number of detections)
#
# Australian fires by year 2014 - 2019
#
# Data downloaded from http://viirsfire.geog.umd.edu/map/viirsMap.php
#
require(ggplot2)
require(readr)
require(dplyr)
# Read de data
#
aufi <- read_csv("Data/NPP_region_17_complete.csv")
# Make stats by year
#
aufi1 <- aufi %>% mutate (year = stringr::str_sub(aufi$date,1,4)) %>% filter(year!=2020) %>% group_by(year) %>% summarise(tot_npp=sum(npp),avg_npp=mean(npp), sd_npp=sd(npp),max_npp=max(npp))
# Plots
#
ggplot(aufi1, aes(x=year,y=max_npp,fill=max_npp)) + theme_bw() + geom_bar(stat="identity") + scale_fill_distiller(palette = "Set1",guide=FALSE) + ylab("Max number of fires")
ggplot(aufi1, aes(x=year,y=tot_npp,fill=tot_npp)) + theme_bw() + geom_bar(stat="identity") + scale_fill_distiller(palette = "Set1",guide=FALSE) + ylab("Total number of fires")
#
# Showing what happen with number of fires>2000 by day
#
aufi1 <- aufi %>% mutate (year = stringr::str_sub(aufi$date,1,4)) %>% mutate(date=as.Date(as.character(date), format = '%Y%m%d'), gt2000=ifelse(npp>2000,TRUE,FALSE)) # %>% filter(date> '2018-10-01')
ggplot(aufi1, aes(x=date,y=npp,color=gt2000)) + theme_bw() + geom_point(size=0.3) + scale_color_brewer(palette = "Set1",guide=FALSE,direction = -1) + ylab("Number of fires") + geom_smooth(se=FALSE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment