Key Observations
In 2021, the top 5 states with the highest number of fire incidences were as follows:
-
Punjab had the highest number of fire incidences, with 1,77,000 - a majority of these were caused by man-made stubble burning during the winter season.
-
Madhya Pradesh had 1,43,923 fire incidences.
-
Odisha had 1,03,919 fire incidences.
-
Chhattisgarh had 87,437 fire incidences.
-
Maharashtra had 75,543 fire incidences.
Fires peak in March and April for Madhya Pradesh, Odisha, Chhattisgarh, and Maharashtra, coinciding with the forest fire season in India.
While the media covers the crop-burning season in Punjab extensively every year, there is a complete lack of coverage on other types of fire incidences, such as forest fires. One primary reason for this lack of coverage is that forest fires in India are generally considered one-off instances and not a regular phenomenon.
To highlight this problem, we have written this tutorial which will teach you how to make API calls on our forest fire dataset to get relevant data and analyze the forest fire-prone areas in India in 2021.
Prerequisites
You will need the following to complete this tutorial.
-
Python
-
Jupyter Notebook
-
Python Packages (Requests, Pandas, Plotnine)
If you need help with installing or setting up Python or Jupyter Notebook, please refer to our previous tutorial, where we have explained this in detail.
Open your Terminal and then type plotnine
pip install requests
pip install pandas
pip install plotnine
Getting the data
-
Start your Jupyter notebook. You do this by going to the Terminal and typing
jupyter notebook
. -
Once the notebook opens, start by importing a few python packages.
-
Once the packages are imported, review our documentation to determine the endpoint for getting data on fire incidences. According to the documentation, the data you are looking for is at the below-mentioned endpoint.
-
Enter the following parameters in the endpoint.
-
Make your API call in the following manner.
-
You will receive the following output.
Formatting Data for Analysis
To analyse the above data, you need to convert it into a pandas dataframe which can be done by following the below-mentioned steps.
-
Import pandas.
-
Convert the
JSON
object into a dataframe. -
Inspect the dataframe using
df.head()
, which will give you a table with the following columns -state
,fires
,co2_emission_estimate
, andaverage frp
values.Top 5 rows in the generated output show fires, CO2 emissions, and FRP values for Madhya Pradesh. -
The table looks great. However, as pandas convert the numbers to strings, this needs to be reconverted back into numbers to analyze. To do this, you have to input the following code.
Counting the Number of Fires and Plotting Them
-
Once the data is ready, you will create a table that shows the total number of fires for every month and every state. You make a pivot table that plots states and the sum of fires in them.
Analysing the data with visualisations
One way to analyse the above data is with a chart. To make a chart, the first step is to import the following packages.
import plotnine #This is the plotting library being used to plot a chart
from plotnine import *
from mizani.breaks import date_breaks #The following two packages assist with some formatting in the chart
from mizani.formatters import date_format
You can plot the total number of fires that have happened across states in the country in 2021 by using the following code. Plotnine is a graphing/charting library that helps you plot. Read here for more details about the library.
#We plot the date and the number of fires at a state level
display(ggplot(df, aes('datetime', 'fires')) + geom_line()
+ facet_wrap('state', nrow=11, ncol=3)
+ scale_x_datetime(breaks=date_breaks('1 month'),
labels=date_format('%m')) + theme(figure_size=(10, 20)))
)
Conclusion
-
A glance at these charts will show you that Punjab, Madhya Pradesh, Odisha, and Chhattisgarh see massive fire seasons.
-
In the case of Punjab, the fire peaks from October to December, i.e., when stubble burning occurs.
-
In the case of forest-heavy states like Chhattisgarh, Madhya Pradesh, and Odisha - the fires peaked from February to April - which is the wildfire season.
For our following tutorial, we will closely examine Madhya Pradesh - a state whose fire problem is not discussed enough. The state had nearly 150,000 fires in 2021 - most of which happened in the forested southern parts - a region that is home to some of India’s most pristine forests and national parks. Monitoring these fires is essential and crucial to protecting our biodiversity.