xrspatial.multispectral.nbr

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

Computes Normalized Burn Ratio. Used to identify burned areas and provide a measure of burn severity.

Parameters
  • nir_agg (DataArray) – near-infrared band (Sentinel 2: Band 8)

  • swir2_agg (DataArray) – shortwave infrared band (Sentinel 2: Band 12) (Landsat 4-7: Band 6) (Landsat 8: Band 7)

  • name (str, optional (default = "nbr")) – Name of output DataArray

Returns

  • xarray.DataArray – 2D array, of the same type as the input, of calculated nbr values. All other input attributes are preserved.

  • Notes

  • ———-

  • Algorithm References

  • - USGS, Landsat Normalized Burn Ratio, https (//www.usgs.gov/land-resources/nli/landsat/landsat-normalized-burn-ratio, Accessed Apr. 21, 2021. # noqa)

  • Examples

  • ———-

  • Imports

  • >>> import numpy as np

  • >>> import xarray as xr

  • >>> import xrspatial

  • Create Sample Band Data

  • >>> np.random.seed(0)

  • >>> nir_agg = xr.DataArray(np.random.rand(4,4),

  • >>> dims = [“lat”, “lon”])

  • >>> height, width = nir_agg.shape

  • >>> _lat = np.linspace(0, height - 1, height)

  • >>> _lon = np.linspace(0, width - 1, width)

  • >>> nir_agg[“lat”] = _lat

  • >>> nir_agg[“lon”] = _lon

  • >>> np.random.seed(4)

  • >>> swir2_agg = xr.DataArray(np.random.rand(4,4), dims = [“lat”, “lon”])

  • >>> height, width = swir2_agg.shape

  • >>> _lat = np.linspace(0, height - 1, height)

  • >>> _lon = np.linspace(0, width - 1, width)

  • >>> swir2_agg[“lat”] = _lat

  • >>> swir2_agg[“lon”] = _lon

  • >>> print(nir_agg, swir2_agg)

  • <xarray.DataArray (lat (4, lon: 4)>)

  • array([[0.5488135 , 0.71518937, 0.60276338, 0.54488318], – [0.4236548 , 0.64589411, 0.43758721, 0.891773 ], [0.96366276, 0.38344152, 0.79172504, 0.52889492], [0.56804456, 0.92559664, 0.07103606, 0.0871293 ]])

  • Coordinates – * lat (lat) float64 0.0 1.0 2.0 3.0
    • lon (lon) float64 0.0 1.0 2.0 3.0

    <xarray.DataArray (lat: 4, lon: 4)>

  • array([[0.96702984, 0.54723225, 0.97268436, 0.71481599], – [0.69772882, 0.2160895 , 0.97627445, 0.00623026], [0.25298236, 0.43479153, 0.77938292, 0.19768507], [0.86299324, 0.98340068, 0.16384224, 0.59733394]])

  • Coordinates

    • lat (lat) float64 0.0 1.0 2.0 3.0

    • lon (lon) float64 0.0 1.0 2.0 3.0 Create NBR DataArray

  • >>> data = xrspatial.multispectral.nbr(nir_agg, swir2_agg)

  • >>> print(data)

  • <xarray.DataArray ‘nbr’ (lat (4, lon: 4)>)

  • array([[-0.2758968 , 0.1330436 , -0.23480372, -0.13489952], – [-0.24440702, 0.49862273, -0.38100421, 0.9861242 ], [ 0.58413122, -0.0627572 , 0.00785568, 0.45584774], [-0.20610824, -0.03027979, -0.39512455, -0.74540839]])

  • Coordinates

    • lat (lat) float64 0.0 1.0 2.0 3.0

    • lon (lon) float64 0.0 1.0 2.0 3.0