About the project

The deforestation of the Amazon forest occurs for several reasons, such as illegal agriculture, natural disasters, urbanization, and mining, being frequent the occurence of burning and or wood extraction. This data set was obtained from a file “inpebrazilianamazonfires1999_2019”, from the National Institute for Space Research (INPE), which brings the number of firespot in the Brazilian Amazon by state, month and year, from 1999 to 2019. The original data are public and were extracted from the INPE website on December 13, 2019. Available at https://www.kaggle.com/mbogernetto/brazilian-amazon-rainforest-degradation?select=inpe_brazilian_amazon_fires_1999_2019.csv.

Loading packages

Subseting only important columns for this project and transforming coordinates variables in a 3d data frame.

library(plotly)
## Warning: package 'plotly' was built under R version 4.0.3
library(tidyr)
library(plyr)

Loading data

data<- read.csv("inpe_brazilian_amazon_fires_1999_2019.csv", header = T)
head(data)
##   year month       state   latitude longitude firespots
## 1 1999     1    AMAZONAS  -2.371113 -59.89993         3
## 2 1999     1    MARANHAO  -2.257395 -45.48783        36
## 3 1999     1 MATO GROSSO -12.660633 -55.05799        18
## 4 1999     1        PARA  -2.474820 -48.54697        87
## 5 1999     1    RONDONIA -12.861700 -60.51310         1
## 6 1999     1     RORAIMA   3.403225 -60.62285        15

Processing the data

groupeddata<-aggregate(firespots~year+state, data, FUN=sum)
head(groupeddata)
##   year state firespots
## 1 1999  ACRE       347
## 2 2000  ACRE       430
## 3 2001  ACRE       829
## 4 2002  ACRE      7985
## 5 2003  ACRE     10523
## 6 2004  ACRE      7271
spreaddata <- spread(groupeddata, state, firespots)
head(spreaddata)
##   year  ACRE AMAPA AMAZONAS MARANHAO MATO GROSSO   PARA RONDONIA RORAIMA
## 1 1999   347   101     1048     4136       28538  20478     7121     220
## 2 2000   430   253      857     4500       17242  18201     5505     362
## 3 2001   829  1300     1297     7979       20795  28590     5062    2415
## 4 2002  7985  3730    10203    20848       79680 106849    39132    2845
## 5 2003 10523  2516    10191    12036       50713  53040    30533    3987
## 6 2004  7271  3413     8083    11443       70422  74214    40824    2221
##   TOCANTINS
## 1       869
## 2       818
## 3      1408
## 4      2601
## 5       861
## 6       746

Plotting the data

f<-list(family="Arial", size=18, color="black")
y<-list(title="Firespots", titlefont=f)
x<-list(title="Year", titlefont=f)

spreaddata %>%
plot_ly(x = ~year, y= ~ACRE, name="Acre", type = 'scatter', mode = 'lines') %>%
  layout(yaxis=y, xaxis=x)%>%
  add_trace(y = ~AMAPA, name = 'Amapá')%>%
  add_trace(y = ~AMAZONAS, name = 'Amazonas')%>%
  add_trace(y = ~MARANHAO, name = 'Maranhão')%>%
  add_trace(y = ~`MATO GROSSO`, name = 'Mato Grosso')%>%
  add_trace(y = ~PARA, name = 'Pará')%>%
  add_trace(y = ~RONDONIA, name = 'Rondônia')%>%
  add_trace(y = ~RORAIMA, name = 'Roraima')%>%
  add_trace(y = ~TOCANTINS, name = 'Tocantins')
## Warning: `arrange_()` is deprecated as of dplyr 0.7.0.
## Please use `arrange()` instead.
## See vignette('programming') for more help
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.

Thank you!