xrspatial.multispectral.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

>>> from xrspatial.datasets import get_data
>>> data = get_data('sentinel-2')  # Open Example Data
>>> nir = data['NIR']
>>> red = data['Red']
>>> from xrspatial.multispectral import savi
>>> # Generate SAVI Aggregate Array
>>> savi_agg = savi(nir_agg=nir, red_agg=red)
>>> nir.plot(aspect=2, size=4)
>>> red.plot(aspect=2, size=4)
>>> savi_agg.plot(aspect=2, size=4)
../../_images/xrspatial-multispectral-savi-1_00.png

(png, hires.png, pdf)#

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

(png, hires.png, pdf)#

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

(png, hires.png, pdf)#

>>> print(nir[y1:y2, x1:x2].data)
[[1519. 1504. 1530. 1589.]
 [1491. 1473. 1542. 1609.]
 [1479. 1461. 1592. 1653.]]
>>> print(red[y1:y2, x1:x2].data)
[[1327. 1329. 1363. 1392.]
 [1309. 1331. 1423. 1424.]
 [1293. 1337. 1455. 1414.]]
>>> print(savi_agg[y1:y2, x1:x2].data)
[[0.0337197  0.03087509 0.0288528  0.03303152]
 [0.0324884  0.02531194 0.02006069 0.03048781]
 [0.03353769 0.02215077 0.02247375 0.03895046]]