Multispectral

Atmospherically Resistant Vegetation Index (ARVI)

xrspatial.multispectral.arvi(nir_agg: xarray.core.dataarray.DataArray, red_agg: xarray.core.dataarray.DataArray, blue_agg: xarray.core.dataarray.DataArray, name='arvi')[source]

Computes Atmospherically Resistant Vegetation Index. Allows for molecular and ozone correction with no further need for aerosol correction, except for dust conditions.

Parameters
  • nir_agg (xarray.DataArray) – 2D array of near-infrared band data.

  • red_agg (xarray.DataArray) – 2D array of red band data.

  • blue_agg (xarray.DataArray) – 2D array of blue band data.

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

Returns

arvi_agg – 2D array arvi values. All other input attributes are preserved.

Return type

xarray.DataArray of the same type as inputs.

References

Examples

>>> print(arvi_agg[100:103, 100: 102])
<xarray.DataArray 'arvi' (y: 3, x: 2)>
array([[0.02676934, 0.02135493],
       [0.02130841, 0.01114413],
       [0.02488688, 0.00816024]])
Coordinates:
  * x        (x) float64 6.01e+05 6.01e+05
  * y        (y) float64 4.699e+06 4.699e+06 4.699e+06
    band     int32 ...
Attributes: (12/13)
    transform:                [ 1.00000e+01  0.00000e+00  6.00000e+05  0.0000... # noqa
    crs:                      +init=epsg:32719
    res:                      [10. 10.]
    is_tiled:                 1
    nodatavals:               nan
    scales:                   1.0
    ...                       ...
    instrument:               Sentinel-2
    Band:                     07
    Name:                     NIR
    Bandwidth (µm):           115
    Nominal Wavelength (µm):  0.842
    Resolution (m):            10

Enhanced Built-Up and Bareness Index (EBBI)

xrspatial.multispectral.ebbi(red_agg: xarray.core.dataarray.DataArray, swir_agg: xarray.core.dataarray.DataArray, tir_agg: xarray.core.dataarray.DataArray, name='ebbi')[source]

Computes Enhanced Built-Up and Bareness Index (EBBI) which allows for easily distinguishing between built-up and bare land areas.

Parameters
  • red_agg (xr.DataArray) – 2D array of red band data.

  • swir_agg (xr.DataArray) – 2D array of shortwave infrared band data.

  • tir_agg (xr.DataArray) – 2D array of thermal infrared band data.

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

Returns

2D array of ebbi values. All other input attributes are preserved

Return type

ebbi_agg = xr.DataArray of same type as inputs

References

Examples

>>> # Imports
>>> import numpy as np
>>> import xarray as xr
>>> from xrspatial import ebbi

>>> # Create Sample Band Data
>>> np.random.seed(1)
>>> red_agg = xr.DataArray(np.random.rand(4,4), dims = ["lat", "lon"])
>>> height, width = red_agg.shape
>>> _lat = np.linspace(0, height - 1, height)
>>> _lon = np.linspace(0, width - 1, width)
>>> red_agg["lat"] = _lat
>>> red_agg["lon"] = _lon

>>> np.random.seed(5)
>>> swir_agg = xr.DataArray(np.random.rand(4,4), dims = ["lat", "lon"])
>>> height, width = swir_agg.shape
>>> _lat = np.linspace(0, height - 1, height)
>>> _lon = np.linspace(0, width - 1, width)
>>> swir_agg["lat"] = _lat
>>> swir_agg["lon"] = _lon

>>> np.random.seed(6)
>>> tir_agg = xr.DataArray(np.random.rand(4,4), dims = ["lat", "lon"])
>>> height, width = tir_agg.shape
>>> _lat = np.linspace(0, height - 1, height)
>>> _lon = np.linspace(0, width - 1, width)
>>> tir_agg["lat"] = _lat
>>> tir_agg["lon"] = _lon

>>> print(red_agg, swir_agg, tir_agg)
<xarray.DataArray (lat: 4, lon: 4)>
array([[4.17022005e-01, 7.20324493e-01, 1.14374817e-04, 3.02332573e-01], # noqa
        [1.46755891e-01, 9.23385948e-02, 1.86260211e-01, 3.45560727e-01], # noqa
        [3.96767474e-01, 5.38816734e-01, 4.19194514e-01, 6.85219500e-01], # noqa
        [2.04452250e-01, 8.78117436e-01, 2.73875932e-02, 6.70467510e-01]]) # noqa
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.22199317, 0.87073231, 0.20671916, 0.91861091],
        [0.48841119, 0.61174386, 0.76590786, 0.51841799],
        [0.2968005 , 0.18772123, 0.08074127, 0.7384403 ],
        [0.44130922, 0.15830987, 0.87993703, 0.27408646]])
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.89286015, 0.33197981, 0.82122912, 0.04169663],
        [0.10765668, 0.59505206, 0.52981736, 0.41880743],
        [0.33540785, 0.62251943, 0.43814143, 0.73588211],
        [0.51803641, 0.5788586 , 0.6453551 , 0.99022427]])
Coordinates:
    * lat      (lat) float64 0.0 1.0 2.0 3.0
    * lon      (lon) float64 0.0 1.0 2.0 3.0

>>> # Create EBBI DataArray
>>> ebbi_agg = ebbi(red_agg, swir_agg, tir_agg)
>>> print(ebbi_agg)
<xarray.DataArray 'ebbi' (lat: 4, lon: 4)>
array([[-2.43983486, -2.58194492,  3.97432599, -0.42291921],
        [-0.11444052,  0.96786363,  0.59269999,  0.42374096],
        [ 0.61379897, -0.23840436, -0.05598088,  0.95193251],
        [ 1.32393891,  0.41574839,  0.72484653, -0.80669034]])
Coordinates:
    * lat      (lat) float64 0.0 1.0 2.0 3.0
    * lon      (lon) float64 0.0 1.0 2.0 3.0

Enhanced Vegetation Index (EVI)

xrspatial.multispectral.evi(nir_agg: xarray.core.dataarray.DataArray, red_agg: xarray.core.dataarray.DataArray, blue_agg: xarray.core.dataarray.DataArray, c1=6.0, c2=7.5, soil_factor=1.0, gain=2.5, name='evi')[source]

Computes Enhanced Vegetation Index. Allows for importved sensitivity in high biomass regions, de-coupling of the canopy background signal and reduction of atmospheric influences.

Parameters
  • nir_agg (xr.DataArray) – 2D array of near-infrared band data.

  • red_agg (xr.DataArray) – 2D array of red band data.

  • blue_agg (xr.DataArray) – 2D array of blue band data.

  • c1 (float, default=6.0) – First coefficient of the aerosol resistance term.

  • c2 (float, default=7.5) – Second coefficients of the aerosol resistance term.

  • soil_factor (float, default=1.0) – Soil adjustment factor between -1.0 and 1.0.

  • gain (float, default=2.5) – Amplitude adjustment factor.

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

Returns

evi_agg – 2D array of evi values. All other input attributes are preserved.

Return type

xarray.DataArray of same type as inputs

References

Examples

>>> print(evi_agg[100:103, 100: 102])
<xarray.DataArray 'evi' (y: 3, x: 2)>
array([[-3.8247012 , -9.51086957],
       [11.81818182,  3.83783784],
       [-8.53211009,  5.48672566]])
Coordinates:
  * x        (x) float64 6.01e+05 6.01e+05
  * y        (y) float64 4.699e+06 4.699e+06 4.699e+06
    band     int32 ...
Attributes: (12/13)
    transform:                [ 1.00000e+01  0.00000e+00  6.00000e+05  0.0000... # noqa
    crs:                      +init=epsg:32719
    res:                      [10. 10.]
    is_tiled:                 1
    nodatavals:               nan
    scales:                   1.0
    ...                       ...
    instrument:               Sentinel-2
    Band:                     07
    Name:                     NIR
    Bandwidth (µm):           115
    Nominal Wavelength (µm):  0.842
    Resolution (m):            10

Green Chlorophyll Index (GCI)

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

Computes Green Chlorophyll Index. Used to estimate the content of leaf chorophyll and predict the physiological state of vegetation and plant health.

Parameters
  • nir_agg (xr.DataArray) – 2D array of near-infrared band data.

  • green_agg (xr.DataArray) – 2D array of green band data.

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

Returns

gci_agg – 2D array of gci values. All other input attributes are preserved.

Return type

xarray.DataArray of the same type as inputs

References

Examples

>>> print(gci_agg[100:103, 100: 102])
<xarray.DataArray 'gci' (y: 3, x: 2)>
array([[0.35625   , 0.33097345],
       [0.3420342 , 0.29551451],
       [0.34822242, 0.28270413]])
Coordinates:
  * x        (x) float64 6.01e+05 6.01e+05
  * y        (y) float64 4.699e+06 4.699e+06 4.699e+06
    band     int32 ...
Attributes: (12/13)
    transform:                [ 1.00000e+01  0.00000e+00  6.00000e+05  0.0000... # noqa
    crs:                      +init=epsg:32719
    res:                      [10. 10.]
    is_tiled:                 1
    nodatavals:               nan
    scales:                   1.0
    ...                       ...
    instrument:               Sentinel-2
    Band:                     07
    Name:                     NIR
    Bandwidth (µm):           115
    Nominal Wavelength (µm):  0.842
    Resolution (m):            10

Normalized Burn Ratio (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 (xr.DataArray) – 2D array of near-infrared band.

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

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

Returns

nbr_agg – 2D array of nbr values. All other input attributes are preserved.

Return type

xr.DataArray of the same type as inputs

References

Examples

print(nbr_agg[100:103, 100: 102])
    <xarray.DataArray 'nbr' (y: 3, x: 2)>
    array([[-0.10251108, -0.1321408 ],
           [-0.09691096, -0.12659354],
           [-0.10823033, -0.14486392]])
    Coordinates:
      * x        (x) float64 6.01e+05 6.01e+05
      * y        (y) float64 4.699e+06 4.699e+06 4.699e+06
        band     int32 ...
    Attributes: (12/13)
        transform:                [ 1.00000e+01  0.00000e+00  6.00000e+05  0.0000... # noqa
        crs:                      +init=epsg:32719
        res:                      [10. 10.]
        is_tiled:                 1
        nodatavals:               nan
        scales:                   1.0
        ...                       ...
        instrument:               Sentinel-2
        Band:                     07
        Name:                     NIR
        Bandwidth (µm):           115
        Nominal Wavelength (µm):  0.842
        Resolution (m):            10

Normalized Burn Ratio 2 (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

>>> 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

Normalized Difference Moisture Index (NDMI)

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

Computes Normalized Difference Moisture Index. Used to determine vegetation water content.

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

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

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

Returns

ndmi_agg – 2D array of ndmi values. All other input attributes are preserved.

Return type

xr.DataArray of same type as inputs

References

Examples

>> print(ndmi_agg[100:103, 100: 102])
<xarray.DataArray 'ndmi' (y: 3, x: 2)>
array([[-0.15868181, -0.19701014],
       [-0.14994299, -0.18686172],
       [-0.17901749, -0.21133603]])
Coordinates:
  * x        (x) float64 6.01e+05 6.01e+05
  * y        (y) float64 4.699e+06 4.699e+06 4.699e+06
    band     int32 ...
Attributes: (12/13)
    transform:                [ 1.00000e+01  0.00000e+00  6.00000e+05  0.0000... # noqa
    crs:                      +init=epsg:32719
    res:                      [10. 10.]
    is_tiled:                 1
    nodatavals:               nan
    scales:                   1.0
    ...                       ...
    instrument:               Sentinel-2
    Band:                     07
    Name:                     NIR
    Bandwidth (µm):           115
    Nominal Wavelength (µm):  0.842
    Resolution (m):            10

Normalized Difference Vegetation Index (NDVI)

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

Computes Normalized Difference Vegetation Index (NDVI). Used to determine if a cell contains live green vegetation.

Parameters
  • nir_agg (xr.DataArray) – 2D array of near-infrared band data.

  • red_agg (xr.DataArray) – 2D array red band data.

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

Returns

ndvi_agg – 2D array of ndvi values. All other input attributes are preserved.

Return type

xarray.DataArray of same type as inputs

References

Examples

>>> print(ndvi_agg[100:103, 100: 102])
<xarray.DataArray 'ndvi' (y: 3, x: 2)>
array([[0.06746311, 0.06177197],
       [0.065     , 0.05064194],
       [0.06709957, 0.04431737]])
Coordinates:
  * x        (x) float64 6.01e+05 6.01e+05
  * y        (y) float64 4.699e+06 4.699e+06 4.699e+06
    band     int32 ...
Attributes: (12/13)
    transform:                [ 1.00000e+01  0.00000e+00  6.00000e+05  0.0000... # noqa
    crs:                      +init=epsg:32719
    res:                      [10. 10.]
    is_tiled:                 1
    nodatavals:               nan
    scales:                   1.0
    ...                       ...
    instrument:               Sentinel-2
    Band:                     07
    Name:                     NIR
    Bandwidth (µm):           115
    Nominal Wavelength (µm):  0.842
    Resolution (m):            10

Soil Adjusted Vegetation Index (SAVI)

xrspatial.multispectral.savi(nir_agg: xarray.core.dataarray.DataArray, red_agg: xarray.core.dataarray.DataArray, soil_factor: float = 1.0, name: str = 'savi')[source]

Computes Soil Adjusted Vegetation Index (SAVI). Used to determine if a cell contains living vegetation while minimizing soil brightness.

Parameters
  • nir_agg (xr.DataArray) – 2D array of near-infrared band data.

  • red_agg (xr.DataArray) – 2D array of red band data.

  • soil_factor (float, default=1.0) – soil adjustment factor between -1.0 and 1.0. When set to zero, savi will return the same as ndvi.

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

Returns

savi_agg – 2D array of savi values. All other input attributes are preserved.

Return type

xr.DataArray of same type as inputs

References

Examples

>>> print(savi_agg[100:103, 100: 102])
<xarray.DataArray 'savi' (y: 3, x: 2)>
array([[0.0337197 , 0.03087509],
       [0.0324884 , 0.02531194],
       [0.03353768, 0.02215077]])
Coordinates:
  * x        (x) float64 6.01e+05 6.01e+05
  * y        (y) float64 4.699e+06 4.699e+06 4.699e+06
    band     int32 ...
Attributes: (12/13)
    transform:                [ 1.00000e+01  0.00000e+00  6.00000e+05  0.0000... # noqa
    crs:                      +init=epsg:32719
    res:                      [10. 10.]
    is_tiled:                 1
    nodatavals:               nan
    scales:                   1.0
    ...                       ...
    instrument:               Sentinel-2
    Band:                     07
    Name:                     NIR
    Bandwidth (µm):           115
    Nominal Wavelength (µm):  0.842
    Resolution (m):            10

Structure Insensitive Pigment Index (SIPI)

xrspatial.multispectral.sipi(nir_agg: xarray.core.dataarray.DataArray, red_agg: xarray.core.dataarray.DataArray, blue_agg: xarray.core.dataarray.DataArray, name='sipi')[source]

Computes Structure Insensitive Pigment Index which helpful in early disease detection in vegetation.

Parameters
  • nir_agg (xr.DataArray) – 2D array of near-infrared band data.

  • red_agg (xr.DataArray) – 2D array of red band data.

  • blue_agg (xr.DataArray) – 2D array of blue band data.

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

Returns

sipi_agg – 2D array of sipi values. All other input attributes are preserved.

Return type

xr.DataArray of same type as inputs

References

Examples

>>> print(sipi_agg[100:103, 100: 102])
<xarray.DataArray 'sipi' (y: 3, x: 2)>
array([[1.23958333, 1.33714286],
       [1.37362637, 1.57746479],
       [1.29032258, 1.64516129]])
Coordinates:
  * x        (x) float64 6.01e+05 6.01e+05
  * y        (y) float64 4.699e+06 4.699e+06 4.699e+06
    band     int32 ...
Attributes: (12/13)
    transform:                [ 1.00000e+01  0.00000e+00  6.00000e+05  0.0000... # noqa
    crs:                      +init=epsg:32719
    res:                      [10. 10.]
    is_tiled:                 1
    nodatavals:               nan
    scales:                   1.0
    ...                       ...
    instrument:               Sentinel-2
    Band:                     07
    Name:                     NIR
    Bandwidth (µm):           115
    Nominal Wavelength (µm):  0.842
    Resolution (m):            10