How to use Landsat Images ( Free ) with QGis 2.8 for NDVI

In the previous two articles, we have discussed ( How
to use Landsat images (free) with ArcGIS (ArcMap) for NDVI
, How
to use Landsat images (free) with ArcGIS Pro for NDVI
) the calculation and
display of NDVI with ArcMap and ArcGis Pro. In this article we will
discuss how to achieve this
operation
with QGis.
To
download Landsat images from Earth Explorer, check out
this
article: How
to use Landsat Images ( Free ) in
your GIS .

Here we will use the raster calculator to calculate the NDVI
, then we will discuss how to create and use a specific colour
gradient for this index.
 

If you work with a Landsat 7 image,
you will load in QGis the bands 3 (red) and
4 (infra-red). If you work
with a Landsat 8 image you will load the bands 4 (red)
and 5 (infra-red).  

To
open the raster calculator , click on the Raster-> Raster Calculator menu  

We will return the formula

NDVI = PIR – R / PIR + R

Where PIR is
the near infrared band and R is the red band

In our example:

(“LE72020272014184ASN00_B4
@ 1″ – “LE72020272014184ASN00_B3 @ 1”) –
(“LE72020272014184ASN00_B4 @ 1” + “LE72020272014184ASN00_B3 @
1″)

The result displays as :  

You can work
directly
using this result but it is
advisable
to refer to a standard symbology .
We
are used to represent NDVI in a complete scale from -1 to +1
( here the result expands from -0.5 to +0.506),
to represent the negative values, which do not correspond to vegetation , by a
gradient of blue, and the positive values , which correspond to vegetation , by
a gradient from green to red passing through the yellow .

Only problem, this gradient
is
not available in   QGis
as such.

To create it , open notepad and type the following text:

<? xml version = “1.0” encoding =
“UTF-8”?>

<svg xmlns =
“http://www.w3.org/2000/svg” version = “1.1” width =
“300px” height = “45px”
viewBox = “0 0
300 45″>

<g>
< defs >
< linearGradient id = “NDVI”
gradientUnits = “ objectBoundingBox spreadMethod
= “pad” x1 = “0%” x2 = “100%” y1 =
“0%” y2 = “0%”>

<stop offset = “0.00%” stop- color
= “ rgb (0,0,255)” stop-opacity = “1.0000”
/>

<stop offset = “49.90%” stop- color
= “ rgb (190,210,255)” stop-opacity =
“1.0000” />

<stop offset = “50.00%” stop- color
= “ rgb (56,168,0)” stop-opacity =
“1.0000” />

<stop offset = “66.60%” stop- color
= “ rgb (255,255,0)” stop-opacity =
“1.0000” />

<stop offset = “100.00%” stop- color
= “ rgb (255,0,0)” stop-opacity = “1.0000”
/>

</ linearGradient >

</ defs >
< rect fill = “ url (#NDVI)”
x = “4” y = “4” width = “292” height =
“37” stroke = “black” stroke-width = “1” />


</ g>
<metadata>
<creator name = “ nasca
version = “1.0” />

<created date = “Mon Mar 23 22:38:20 2015”
/>

</ metadata>
</ svg>

Register
this
file
with the name NDVI.svg in the \ Program Files \
QGIS Wien \ apps \ qgis \ resources \
cpt -City-qgis-min \ cb
\ div

Now we are going apply this gradient to the resulting raster of the NDVI calculation: Double click on the legend of the raster to open the Properties window
In the Style tab , change the rendering type to “Pseudo colour single band”
Change the values from Min =-1 and from Max = 1.   

In the drop down  list of colour palette, go to  the last line and click New color palette

In the Color Palette Type , select
-City cpt and
click
OK

The palette cpt -City opens   

Open “Diverging” item and select cb/ div to find the ndvi palette that you have created .
Click on one of these, then click OK. Leave the default name and click OK
In Mode select equal intervals .
In Class select , for example , 20 .
Click the Sort button
You will see the scale to be applied to the raster.   

Click
OK to close the properties layer window and see the final result :
 

Leave a Reply

Your email address will not be published. Required fields are marked *