Importance of Fire Prediction Dataset

Early this month, residents in northwest Washington in the US were asked to evacuate their houses as firefighters rushed to contain the Bolt Creek fire that spread quickly across the region. Having scorched over 9,400 acres of land, it was one of the several wildfires that raged uncontrollably this month as wildfires wreaked havoc in Kazakhstan, France and Canada, among other places.

With the climate crisis worsening, the last few years have seen a sharp rise in the frequency and intensity of wildfires. In April 2020, for example, fire alerts around the world increased by 13% compared to the previous year, which had already witnessed a new record for fires. Wildfires have a devastating impact on almost all aspects of life, ranging from their effect on public health to wildlife, from having cultural implications to impacting businesses. You can read more about the impact of wildfires in our blog “Decoding Wildfires: Understanding The New Normal”.

Recognizing the importance of fire prediction, the team at Blue Sky Analytics developed a Fire Predictions dataset that holds tremendous potential in bringing down the risks and costs associated with wildfires. In this tutorial, we will explore how Blue Sky Analytics’ Fire Prediction dataset can be used to forecast any biomass fire events 7 days in advance in Germany.

💡 Before we can query anything from the BSA’s APIs, we need the shape IDs for the relevant regions. For this purpose, we will utilize the Shape Explorer tool found in SpaceTime. Shape Explorer aims to make it possible for users to use consistent shape IDs that are unique and represent a specific boundary at different administrative levels. This unique shapeId lets us filter data spatially and fetch all data falling within the shape. It helps in preventing any non-uniformity that can result from location names which may differ from person to person.

Setting up the environment and fetching the data

Fire up Jupyter Notebook in the terminal by typing jupyter notebook and installing the required packages. For more assistance on fetching the data refer to our previous tutorial here.

To ensure all the plots from this analysis are correctly reproduced, the following packages will be required.

# This package helps you reach out to the API
import requests 
# This package is necessary to ensure you receive data in a JSON format
import json  
# Required to reproduce the plots included in this tutorial
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import plotly.express as px
import geopandas as gpd
import io
import zipfile

%matplotlib inline

After the packages have been imported, the next step lies in determining the endpoint, which in turn will fetch the Fire Predictions data, and this can be found in Dev Portal docs. The parameters: shapeId, duration, startDate, endDate will define the region’s data that we are interested in accessing.

# Getting the fire prediction data for Germany
params_germany = {
    "api-key": "YOUR BSA API KEY HERE",
    "shapeId": "SHAPE ID FROM SHAPE EXPLORER",
    "duration": "1w",
    "startDate": "2022-08-08T00:00:00.000Z",
    "endDate": "2022-08-14T00:00:00.000Z",
    "raw": "true",
    "adminLevelBucket":"2",
}

# Making an API call
germany_data = requests.get(
    "https://gateway.blueskyhq.io/api/fire-predictions?",
    params=params_germany).json()

# Getting the data in a more accessible format -> Pandas Dataframe
germany_fires = pd.DataFrame(germany_data['data'])

Combined dataframe

Combined dataframe

The fire data with the parameters predicted_fires, latitude, and longitude for each date in the 7-day period can be accessed in the following manner. Here we are getting the data from Aug 8 till Aug 14. The data frames named aug8, aug9, and so on are storing the fires data for the respective dates.

# separating the fires data according to respective dates
for n in range(0, 7):
    globals()['aug%s' % n+8] = pd.DataFrame(germany_fires['points'][n])
Forecasted fires for Aug 9, 2022
Forecasted fires for Aug 9, 2022
Forecasted fires for Aug 9, 2022
Forecasted fires for Aug 9, 2022
Forecasted fires for Aug 9, 2022
Forecasted fires for Aug 9, 2022

We will use the openly available shapefile of Germany with state boundaries made available by the University of California Davis.

# getting the shapefile for Germany from 
local_path = 'tmp/'
url = "https://biogeo.ucdavis.edu/data/diva/adm/DEU_adm.zip"

r = requests.get(url)
z = zipfile.ZipFile(io.BytesIO(r.content))
z.extractall(path=local_path)

# visualizing the shape file
gdf = gpd.read_file(local_path + '/DEU_adm1.shp')
gdf.plot(color='white',
         edgecolor='black')
plt.show()

Administrative boundary of Germany

Administrative boundary of Germany

Visualizing the day-wise fires

# list containing all the data frames
data = [aug8, aug9, aug10, aug11, aug12, aug13, aug14]

# date corresponding to forecasted fires
dates = ['Aug 8', 'Aug 9', 'Aug 10', 'Aug 11', 'Aug 12', 'Aug 13', 'Aug 14']

gdf = gpd.read_file(local_path + '/DEU_adm1.shp')

fig, ax = plt.subplots(2, 4, figsize=(25, 25))
fig.subplots_adjust(hspace=0.05, wspace=.25)

ax = ax.ravel()

for i in range(7):
    plt.subplot(2, 4, i+1)
    gdf.plot(color='lightgrey', edgecolor='gray', ax=ax[i])

    sns.scatterplot(data=data[i],
                    x="longitude",
                    y="latitude",
                    hue="predicted_fires",
                    palette="YlOrRd",
                    size="predicted_fires",
                    sizes=(20, 200),
                    hue_norm=(0, 7),
                    ax=ax[i])
    
    plt.title('Aug ' + str(i + 8))

The day-wise forecasted fires over have been visualized below:

Predicted Fires over Germany between August 8 to August 14, 2022. © Blue Sky Analytics, 2022

Predicted Fires over Germany between August 8 to August 14, 2022. © Blue Sky Analytics, 2022

In conclusion

Our fire prediction dataset holds the potential to create a paradigm shift in the current fire management approach and significantly minimize risks and losses. A report claims that wildfires will increase by a third by 2050 and by 50% by the end of this century. Thus, as the crisis is poised to worsen, the relevance of this dataset is further enhanced.

In addition, the current approach, which focuses on quick detection and suppression of fires, is hugely insufficient. These traditional methods are short-term solutions which are both uneconomical and unsustainable in the long run. For example, a central estimate in the United States is that the total cost of fire damages is 20 times more than the suppression costs. Thus, if efficient solutions are not enforced, losses associated with wildfires will only get exponentially higher.

Apart from lowering the impact on human lives and the ecosystem, fire predictions can also help businesses significantly. The dataset will be of great benefit, especially to key industries that are susceptible to wildfire risks, such as insurance companies, natural asset firms, municipal bond traders and energy and utility companies, among others. The fire prediction dataset can minimize the material and financial losses caused by fire damage to a company’s infrastructure and assets. It can also bring down the losses resulting from power shut-offs, business closures, and insurance payouts.