Satellite Imagery Analysis using Python — Soil Indices (SAVI and VARI)

Hem Bdr Bhattarai
3 min readMay 25, 2022

--

  • There is a large number of spectral indices that can analyze various aspects such as vegetation, water resources, snow, soil, fire, among others. The satellites better known as Landsat and Sentinel offer the opportunity to perform various operations with their bands, the result can be converted into a spectral index.
  • Bare soil is a critical element in the urban landscape and plays an essential role in urban environments. Yet, the separation of bare soil and other land cover types using remote sensing techniques remains a significant challenge. There are several remote sensing-based spectral indices for barren detection, but their effectiveness varies depending on land cover patterns and climate conditions. Within this research, we introduced a modified bare soil index (MBI) using shortwave infrared (SWIR) and near-infrared (NIR) wavelengths

Downloading data set

Download: https://tei.ai/XvPbMeldv

Let’s start coding by importing the necessary packages,

from glob import glob
import earthpy as et
import earthpy.spatial as es
import earthpy.plot as ep

import rasterio as rio

import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import ListedColormap
import plotly.graph_objects as go
np.seterr(divide= "ignore", over= "warn", under= "ignore", invalid="ignore")

Viewing Satellite Images

S_bands = glob("*B?*.tiff")  
S_bands.sort()

Verify Imported Satellite Images Bands

S_bands

Converting Bands to stack array

l = []

for i in S_bands:
with rio.open(i, 'r') as f:
l.append(f.read(1))
image_array = np.stack(l)

Visualize Bands

ep.plot_bands(image_array, cmap = "gist_earth", figsize = (20, 12), cols = 6,cbar = False)plt.show()

Visible Atmospherically Resistant Index (VARI)

  • The Visible Atmospherically Resistant Index (VARI) is designed to emphasize vegetation in the visible portion of the spectrum, while mitigating illumination differences and atmospheric effects. It is ideal for RGB or color images; it utilizes all three color bands.
  • VARI = (Green - Red)/ (Green + Red - Blue)
  • * Green = pixel values from the green band
  • * Red= pixel values from the red band
  • * Blue = pixel values from the blue band

Lets code to calculate VARI

vari = (image_array[2] - image_array[3])/ (image_array[2] + image_array[3] - image_array[1])ep.plot_bands(vari, cmap="RdYlGn", cols=1, vmin=-1, vmax=1, figsize=(10, 14))

plt.show()

Soil Adjusted Vegetation Index (SAVI)

  • The Soil-Adjusted Vegetation Index (SAVI) is a vegetation index that attempts to minimize soil brightness influences using a soil-brightness correction factor. This is often used in arid regions where vegetative cover is low.
  • * SAVI = ((NIR - Red) / (NIR + Red + L)) x (1 + L)
  • NIR = pixel values from the near infrared band
  • Red = pixel values from the near red band
  • L = amount of green vegetation cover
  • NIR and Red refer to the bands associated with those wavelengths. The L value varies depending on the amount of green vegetative cover. Generally, in areas with no green vegetation cover, L=1; in areas of moderate green vegetative cover, L=0.5; and in areas with very high vegetation cover, L=0 (which is equivalent to the NDVI method). This index outputs values between -1.0 and 1.0.

Lets code to calculate SAVI

L = 0.5
savi = ((image_array[7] - image_array[3]) / (image_array[7] + image_array[3] + L)) * (1 + L)
ep.plot_bands(savi, cmap="RdYlGn", cols=1, vmin=-1, vmax=1, figsize=(10, 14))plt.show()

--

--

Hem Bdr Bhattarai

Organized and adaptable GIS Analyst with experience and developer in data analysis and web mapping.