xrspatial.multispectral.nbr2

xrspatial.multispectral.nbr2(swir1_agg: xarray.core.dataarray.DataArray, swir2_agg: xarray.core.dataarray.DataArray, name='nbr2')[source]

Computes Normalized Burn Ratio 2 “NBR2 modifies the Normalized Burn Ratio (NBR) to highlight water sensitivity in vegetation and may be useful in post-fire recovery studies.” 1

Parameters
  • swir1_agg (xr.DataArray) – 2D array of near-infrared band data. shortwave infrared band (Sentinel 2: Band 11) (Landsat 4-7: Band 5) (Landsat 8: Band 6)

  • swir2_agg (xr.DataArray) – 2D array of shortwave infrared band data. (Landsat 4-7: Band 6) (Landsat 8: Band 7)

  • name (str default='nbr2') – Name of output DataArray.

Returns

nbr2_agg – 2D array of nbr2 values. All other input attributes are preserved.

Return type

xr.DataArray of same type as inputs.

Notes

1

https://www.usgs.gov/land-resources/nli/landsat/landsat-normalized-burn-ratio-2 # noqa

Examples

import matplotlib.pyplot as plt
from xrspatial.multispectral import nbr2
from xrspatial.datasets import get_data

# Open Example Data
data = get_data('sentinel-2')

swir1 = data['SWIR1']
swir2 = data['SWIR2']

# Generate NBR2 Aggregate Array
nbr2_agg = nbr2(swir1_agg = swir1,
                swir2_agg = swir2)

# Plot SWIR1 Band
swir1.plot(cmap = 'Greys', aspect = 2, size = 4)
plt.title("SWIR1 Band")
plt.ylabel("latitude")
plt.xlabel("longitude")

# Plot SWIR2 Band
swir2.plot(cmap = 'Greys', aspect = 2, size = 4)
plt.title("SWIR2 Band")
plt.ylabel("latitude")
plt.xlabel("longitude")

# Plot NBR2
nbr2_agg.plot(cmap = 'Greys', aspect = 2, size = 4)
plt.title("NBR2")
plt.ylabel("latitude")
plt.xlabel("longitude")
../../_images/xrspatial-multispectral-nbr2-1_00.png

(png, hires.png, pdf)

../../_images/xrspatial-multispectral-nbr2-1_01.png

(png, hires.png, pdf)

../../_images/xrspatial-multispectral-nbr2-1_02.png

(png, hires.png, pdf)

>>> print(nbr2_agg[100:103, 100: 102])
<xarray.DataArray 'nbr' (y: 3, x: 2)>
array([[0.05709955, 0.06660324],
       [0.053814  , 0.0617284 ],
       [0.07218576, 0.06857143]])
Coordinates:
  * x        (x) float64 6.02e+05 6.02e+05
  * y        (y) float64 4.698e+06 4.698e+06 4.698e+06
    band     int32 ...
Attributes: (12/13)
    transform:                [ 2.00000e+01  0.00000e+00  6.00000e+05  0.0000... # noqa
    crs:                      +init=epsg:32719
    res:                      [20. 20.]
    is_tiled:                 1
    nodatavals:               nan
    scales:                   1.0
    ...                       ...
    instrument:               Sentinel-2
    Band:                     11
    Name:                     SWIR1
    Bandwidth (µm):           90
    Nominal Wavelength (µm):  1.610
    Resolution (m):            20