xrspatial.multispectral.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 (xarray.DataArray) – 2D array of near-infrared band data. (Sentinel 2: Band 8)

  • red_agg (xarray.DataArray) – 2D array of red band data. (Sentinel 2: Band 4)

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

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

Returns

2D array, of the same type as the input, of calculated sipi values. All other input attributes are preserved.

Return type

xarray.DataArray

Algorithm References: - Wikipedia, Enhanced Vegetation Index, https://en.wikipedia.org/wiki/Enhanced_vegetation_index, Accessed Apr. 21, 2021. # noqa

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(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(2)
>>> blue_agg = xr.DataArray(np.random.rand(4,4), dims = ["lat", "lon"])
>>> height, width = blue_agg.shape
>>> _lat = np.linspace(0, height - 1, height)
>>> _lon = np.linspace(0, width - 1, width)
>>> blue_agg["lat"] = _lat
>>> blue_agg["lon"] = _lon
>>> print(nir_agg, red_agg, blue_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([[4.17022005e-01, 7.20324493e-01, 1.14374817e-04, 3.02332573e-01],
   [1.46755891e-01, 9.23385948e-02, 1.86260211e-01, 3.45560727e-01],
   [3.96767474e-01, 5.38816734e-01, 4.19194514e-01, 6.85219500e-01],
   [2.04452250e-01, 8.78117436e-01, 2.73875932e-02, 6.70467510e-01]])
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.4359949 , 0.02592623, 0.54966248, 0.43532239],
   [0.4203678 , 0.33033482, 0.20464863, 0.61927097],
   [0.29965467, 0.26682728, 0.62113383, 0.52914209],
   [0.13457995, 0.51357812, 0.18443987, 0.78533515]])
Coordinates:
* lat      (lat) float64 0.0 1.0 2.0 3.0
* lon      (lon) float64 0.0 1.0 2.0 3.0

Create ARVI DataArray >>> data = xrspatial.multispectral.sipi(nir_agg, red_agg, blue_agg) >>> print(data) <xarray.DataArray ‘sipi’ (lat: 4, lon: 4)> array([[ 8.56038534e-01, -1.34225137e+02, 8.81124802e-02,

4.51702802e-01],

[ 1.18707483e-02, 5.70058976e-01, 9.26834671e-01,

4.98894015e-01],

[ 1.17130642e+00, -7.50533112e-01, 4.57925444e-01,

1.58116224e-03],

[ 1.19217212e+00, 8.67787369e+00, -2.59811674e+00,

1.19691430e+00]])

Coordinates: * lat (lat) float64 0.0 1.0 2.0 3.0 * lon (lon) float64 0.0 1.0 2.0 3.0