1

I've followed this tutorial to calculate the dNBR Index, using the given sample tif files which contain a burned area. My results were as shown on the tutorial. So far so good.

Then I tried to calculate the Burned Area Index (BAI) after making a few modifications on the above tutorial's code. The result is an empty plot.

This is my implementation:

(Note: The code downloads tif images from here)

from glob import glob
import matplotlib.pyplot as plt
import xarray as xr
import rioxarray as rxr
import earthpy.plot as ep
import earthpy as et
import os

def combine_tifs(tif_list):
    """A function that combines a list of tifs in the same CRS
    and of the same extent into an xarray object

    Parameters
    ----------
    tif_list : list
    A list of paths to the tif files that you wish to combine.

    Returns
    -------
    An xarray object with all of the tif files in the listmerged into
    a single object.

    """

    out_xr = []
    for i, tif_path in enumerate(tif_list):
    out_xr.append(rxr.open_rasterio(tif_path, masked=True).squeeze())
    out_xr[i]["band"] = i+1

    return xr.concat(out_xr, dim="band")

path_to_downloaded_data = et.data.get_data('cold-springs-fire', replace=True)

all_landsat_bands_path = glob(os.path.join(path_to_downloaded_data,
                                       "landsat_collect",
                                       "LC080340322016072301T1-SC20180214145802",
                                       "crop",
                                       "*band[1-7]*.tif"))

all_landsat_bands_path.sort()
all_bands = combine_tifs(all_landsat_bands_path)

red_square = (0.1 - all_bands[3]) * (0.1 - all_bands[3])
nir_square = (0.06 - all_bands[4]) * (0.06 - all_bands[4])
burned_area_index = 1 / (red_square + nir_square)

fig1, ax = plt.subplots(figsize=(12, 12))
fig1 = plt.gcf()
ep.plot_bands(burned_area_index,
          cmap='PiYG',
          scale=False,
          cbar=False,  # Change this to TRUE to display the color bar
          ax=ax,
          vmin=-1, vmax=1,
          title="BAI")
plt.show()

The values of the burned_area_index array are very low, in the magnitude of 10^-7.

My question is, if the formula is correct, what might be the problem that results in an empty plot?

2
  • 1
    Look at the range of the values in the data. You're using Level 1 data which is scaled DN. The formula you linked to requires reflectance (0.0 - 1.0). Either calculate TOA reflectance (gis.stackexchange.com/q/166072/2856) or download the surface reflectance product.
    – user2856
    Apr 27, 2021 at 21:07
  • As user2856 pointed out, you need products with bands expressed in reflectance. With these changes, threshold value for discriminating burnt areas is > 89.
    – xunilk
    Apr 29, 2021 at 0:40

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.