Wednesday, November 12, 2014

Computation of Enhanced Vegetation Index Using Spectral Python

This example was demonstrated in masters level course GIS and Remote Sensing, See references for details. Most of commands are taken from user guide [SpectralPython] whereas theoretical basis are discussed in [MODIS-VI_UserGuide]. This post assumes software is already installed and data is locally available. Invoke ipython --pylab=wx at command prompt.

In [1]: from spectral import *
In [2]: img = open_image('92av3c.lan')
In [3]: blu, red, nir = img[:,:,9], img[:,:,29], img[:,:,43]
In [4]: evi = 2.5 * (nir - red) / (nir + 6 * red - 7.5 * blu + 1)
In [5]: view = imshow(evi)

References: [SpectralPython] [MODIS-VI_UserGuide]

The output image is pasted below.


1 comment:

  1. please tell me how to work for command 1 and 2,because it wont work for me in spyder python.

    from spectral import open_image
    img = open_image("92AV3C.lan")
    view = imshow(img, (29, 19, 9))

    eror looks like :
    from spectral import *
    Traceback (most recent call last):

    File "", line 1, in
    from spectral import *

    File "E:\spyder\tes\spectral\__init__.py", line 44, in
    from spectral import (open_image, load_training_sets, save_training_sets,

    ImportError: cannot import name 'open_image'

    please help what is the problem?

    ReplyDelete