Difference between revisions of "Raster algebra: calculating indexes"

From Geomaster, Lda
Jump to navigation Jump to search
(Created page with "=== Calculating indexes === The Band calc allows for the raster calculation for bands (i.e. calculation of pixel values) using NumPy functions. Raster bands must be already l...")
 
 
Line 50: Line 50:
 
==== Calculating NDWI ====
 
==== Calculating NDWI ====
  
NDWI stands for Normalized Difference Water Index. There are authors using this index to '''Monitoring Crop Field Soil Moisture'''.
+
NDWI stands for '''Normalized Difference Water Index'''.
 +
 
 +
References:
 +
 
 +
[http://www.quadratic.be/en/le-suivi-de-letat-hydrique-ndwi-des-cultures-par-les-series-temporelles-sentinel-2/ Monitoring Crop Field Soil Moisture (NDWI) Using Sentinel-2 Temporal Series]
  
 
Let's create the NDWI for several Sentinel-2 images to have some insights about soil moisture.
 
Let's create the NDWI for several Sentinel-2 images to have some insights about soil moisture.
 +
 +
<syntaxhighlight lang="python">
 +
( "bandset#b8" - "bandset#b9" ) / ( "bandset#b8"+ "bandset#b9" ) @NDWI_20180606
 +
</syntaxhighlight>
 +
 +
[[File:Captura de ecrã de 2018-06-11 23-17-52.png]]
 +
 +
[[File:Captura de ecrã de 2018-06-11 23-17-38.png]]
 +
 +
[[File:Captura de ecrã de 2018-06-11 23-17-44.png]]
 +
 +
Clip the images
 +
 +
Calculate NDWI
 +
 +
<syntaxhighlight lang="python">
 +
( "bandset#b1" - "bandset#b2" ) / ( "bandset#b1"+ "bandset#b2" ) @NDWI_20180507
 +
</syntaxhighlight>

Latest revision as of 21:26, 11 June 2018

Calculating indexes

The Band calc allows for the raster calculation for bands (i.e. calculation of pixel values) using NumPy functions. Raster bands must be already loaded in QGIS. All rasters are listed in the Band list table.

Each raster in the has one variable and one name assigned. We can use the variable or the name. If we use the name, it must be written between double quotes.

When we have a band set defined, it is easier to identify each of the bands with "bandset#b1", "bandset#b2", etc. Besides that, we can also identify some special bands in the Band set by its name:

  • "#BLUE#": the band with the center wavelength closest to 0.475 μm;
  • "#GREEN#": the band with the center wavelength closest to 0.56 μm;
  • "#RED#": the band with the center wavelength closest to 0.65 μm;
  • "#NIR#": the band with the center wavelength closest to 0.85 μm;

Operators and functions

Besides normal operations, like + (plus), - (minus), etc, and some functions like sin, cos, etc, we can use and NumPy function.

Calculating NDVI

Let's create the NDVI index to give examples of the band set expressions.

To create a new raster with NDVI values, we can use the default expression (available in the dropdown box):

( "#NIR#" - "#RED#" ) / ( "#NIR#" + "#RED#" ) @NDVI_20180606_a

The above expression uses the special names "#NIR#" and "#RED#" to select the bands from the Band set.

Captura de ecrã de 2018-06-11 21-44-27.png

The same index could be computed with the expression:

( "bandset#b7" - "bandset#b3" ) / ( "bandset#b7" + "bandset#b3" ) @NDVI_20180606_b

The above expression works for our Sentinel-2 Band set. Sentinel-2 NIR is band 08, so it is the 7th band in our band set.

NOTE: the last expression token @NDVI_20180606_a defines the layer name. It is convenient to save the TIF output with the same name.

After running the calculation, a new raster layer is added to QGIS. Check the pixel values. They should be in the range [-1, 1].

Captura de ecrã de 2018-06-11 22-01-24.png

Calculating EVI

EVI index is anothe rpredefine index. Just select it from the drop down combobox.

Calculating NDWI

NDWI stands for Normalized Difference Water Index.

References:

Monitoring Crop Field Soil Moisture (NDWI) Using Sentinel-2 Temporal Series

Let's create the NDWI for several Sentinel-2 images to have some insights about soil moisture.

( "bandset#b8" - "bandset#b9" ) / ( "bandset#b8"+ "bandset#b9" ) @NDWI_20180606

Captura de ecrã de 2018-06-11 23-17-52.png

Captura de ecrã de 2018-06-11 23-17-38.png

Captura de ecrã de 2018-06-11 23-17-44.png

Clip the images

Calculate NDWI

( "bandset#b1" - "bandset#b2" ) / ( "bandset#b1"+ "bandset#b2" ) @NDWI_20180507