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

nir_agg: xarray.DataArray

2D array of near-infrared band data. (Sentinel 2: Band 8)

green_agg: xarray.DataArray

2D array of green band data. (Sentinel 2: Band 3)

name: str, optional (default = “gci”)

Name of output DataArray

xarray.DataArray

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

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(3)
>>> green_agg = xr.DataArray(np.random.rand(4,4),
>>> dims = ["lat", "lon"])
>>> height, width = green_agg.shape
>>> _lat = np.linspace(0, height - 1, height)
>>> _lon = np.linspace(0, width - 1, width)
>>> green_agg["lat"] = _lat
>>> green_agg["lon"] = _lon
>>> print(nir_agg, green_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.5507979 , 0.70814782, 0.29090474, 0.51082761],
       [0.89294695, 0.89629309, 0.12558531, 0.20724288],
       [0.0514672 , 0.44080984, 0.02987621, 0.45683322],
       [0.64914405, 0.27848728, 0.6762549 , 0.59086282]])
Coordinates:
  * lat      (lat) float64 0.0 1.0 2.0 3.0
  * lon      (lon) float64 0.0 1.0 2.0 3.0

Create GCI DataArray >>> data = xrspatial.multispectral.gci(nir_agg, green_agg) >>> print(data) <xarray.DataArray ‘gci’ (lat: 4, lon: 4)> array([[-3.60277089e-03, 9.94360715e-03, 1.07203010e+00,

6.66674578e-02],

[-5.25554349e-01, -2.79371758e-01, 2.48438213e+00,

3.30303328e+00],

[ 1.77238221e+01, -1.30143021e-01, 2.55001824e+01,

1.57741801e-01],

[-1.24932959e-01, 2.32365855e+00, -8.94956683e-01,

-8.52538868e-01]])

Coordinates:
  • lat (lat) float64 0.0 1.0 2.0 3.0

  • lon (lon) float64 0.0 1.0 2.0 3.0