Spectral indices

From AWF-Wiki
(Difference between revisions)
Jump to: navigation, search
(Spectral indices using Processing Toolbox)
(Several spectral indices at once using OTB)
 
(42 intermediate revisions by one user not shown)
Line 1: Line 1:
= Vegetation index using the Raster Calculator =  
+
= Spectral vegetation index using Raster Calculator =  
* Click the {{button|text=Open Data Source Manager}} [[Image:QGIS_3.0_datasource.png|30px]] and then {{button|text=Add raster layer}} [[Image:QGIS_2.0_addrast.png|20px]] and select the file  ''/geodata_lab01/raster/s2/Subset_S2A_MSIL2A_20170619T_MUL.tif''.
+
* Click the {{button|text=Open Data Source Manager}} [[Image:QGIS_3.0_datasource.png|30px]] and then {{button|text=Add raster layer}} [[Image:QGIS_2.0_addrast.png|20px]] and select the file  ''/geodata/lucc/s2/Subset_S2A_MSIL2A_20170619T_MUL.tif''.
* Check the rank and spectral range of bands in the multiband file (e.g. see table [[Changing Raster Layer Style]]).
+
* Check the rank and spectral range of bands in the multiband file (e.g. see table [[Changing Raster Layer Style]]). Here the rank of 10 bands  is B2,B3,B4,B5,B6,B7,B8,B8A,B11,B12.
* After clicking {{button|text=Open}}, the raster layer appears in the QGIS canvas.
+
 
* Click {{mitem|text=Raster --> Raster calculator}}.
 
* Click {{mitem|text=Raster --> Raster calculator}}.
 
* A powerful normalization is realized by the ''normalized difference vegetation index'' that forms the basis of most vegetation indices $NDVI = (Nir - Red) / (Nir + Red)$. It can be implemented using {{tool|text=Raster Calculator}} as seen in the following screenshot:
 
* A powerful normalization is realized by the ''normalized difference vegetation index'' that forms the basis of most vegetation indices $NDVI = (Nir - Red) / (Nir + Red)$. It can be implemented using {{tool|text=Raster Calculator}} as seen in the following screenshot:
Line 8: Line 7:
 
* Define path and file name of the output layer. {{button|text=OK}}.
 
* Define path and file name of the output layer. {{button|text=OK}}.
 
* Map visualization: Open the raster layer properties by right-clicking the ndvi raster in the [[TOC]] selecting {{button|text=Properties}}, or by simply double clicking.  
 
* Map visualization: Open the raster layer properties by right-clicking the ndvi raster in the [[TOC]] selecting {{button|text=Properties}}, or by simply double clicking.  
* Select the {{button|text=Style}} tab. Under {{button|text=Render type}} select {{button|text=Singleband pseudocolor}}.
+
* Select the {{button|text=Symbology}} tab. Under '''Render type''' select {{button|text=Singleband pseudocolor}}.
** Open the In the pulldown menu of {{button|text=Color ramp}} by clicking on [[File:Qgis_pull_down.png]] Select {{mitem|text= All color ramps --> RdYlGn}}. In the {{button|text=Mode}}  select {{button|text=Equal interval}}. Set the number of {{button|text=Classes}} to 10 and click {{button|text=Classify}}.  
+
** Open the the pulldown menu of {{button|text=Color ramp}} by clicking on [[File:Qgis_pull_down.png]] Select {{mitem|text= All color ramps --> RdYlGn}}. Under {{button|text=Mode}}  select {{button|text=Equal interval}}. Set the number of {{button|text=Classes}} to 10. In the pulldown menu of {{button|text=Color ramp}} select {{mitem|text=Invert Color Ramp}}.
 +
 
 
** To finish, click {{button|text=Apply}} (see '''Fig. A''').
 
** To finish, click {{button|text=Apply}} (see '''Fig. A''').
  
= Spectral indices using Processing Toolbox =
+
= Several spectral indices at once using OTB =
 
A convenient module for calculating one or several spectral indices at the same time can be found in the QGIS processing toolbox.  
 
A convenient module for calculating one or several spectral indices at the same time can be found in the QGIS processing toolbox.  
* Type text=Radiometric}} into the search field and find the {{button|text=OTB --> Feature Extraction --> Radiometric Indices)}} tool.  
+
* Type {{typed|text=Radiometric}} into the search field and find the {{button|text=OTB --> Feature Extraction --> Radiometric Indices}} tool.  
 
* Open it with a double click.  
 
* Open it with a double click.  
 
* Assign the bands in the multiband file to the correct spectral sensitivity.
 
* Assign the bands in the multiband file to the correct spectral sensitivity.
* in the text field ''Available Radiometric Indices'' type:
+
* If you want to calculate a single spectral index type in the text field ''Available Radiometric Indices'': {{typed|text="Vegetation:NDVI"}}
{{typed|text=Vegetation:NDVI}} {{button|text=Enter}}
+
* If you want to calculate several spectral indices at once and store them in a multiband file click {{button|text=Help}} to find definitions of available spectral indices in three categories (vegetation, soil, water) and relevant channels of the input multiband image.
{{typed|text=Water:NDWI}} {{button|text=Enter}}
+
* In the text field ''Available Radiometric Indices'' type with apostrophs:
{{typed|text=Soil:BI2}} {{button|text=Enter}}.
+
{{typed|text="Vegetation:NDVI Water:NDWI2 Soil:BI2"}}
Click {{button|text=Run}}.  
+
* Click {{button|text=Run}}.
[[File:Qgis_radio_index.png|left|200px]]
+
 
 +
[[File:Qgis_radiometric_composite.png|left|400px]]
 +
 
  
= Spectral indices using OTB graphical user interface =
 
If you want to calculate several spectral indices and stack the resulting layers into a new multiband file use the OTB Graphical User Interface.
 
* In the Search box on the Windows Start menu type {{typed|text=OSGeo4W Shell}}. You should be able to open the shell by clicking on it.
 
* Type into the shell: {{typed|text=otbgui_RadiometricIndices}}. Select a multiband input file and assign the spectral ranges to the bands as seen in the screenshot.
 
[[File:Qgis_otbgui_radio.png|400px]]
 
* In the ''Documentation'' tab you'll find an overview on available spectral indices in three categories (vegetation, water, soil) and relevant channels of the input image. Several Indices can be selected in the drop-downlist. Note, the rank of marking defines the order of bands in the resulting multiband file. Mark SAVI, NDWI and BI2 in the list.
 
* Display the output multiband spectral indices image as a color composite in the canvas ('''Fig. B''').
 
 
{| class="wikitable"
 
{| class="wikitable"
| style="border: 0pt" | [[file:Qgis_ndvi_pseudo.png|thumb|left|400px|'''Figure A:''' Single band NDVI displayed with color table ''RdYlGn'']]
+
| style="border: 0pt" | [[file:Qgis_ndvi_pseudo.png|thumb|left|400px|'''Figure A: ''' Single band '''NDVI''' (color table = RdYlGn)]]
| style="border: 0pt" | [[file:Qgis_vi_composite.png|thumb|left|400px|'''Figure B:''' Color composite of three spectral indices: SAVI, NDWI and BI2]]
+
| style="border: 0pt" | [[file:Qgis_vi_composite.png|thumb|left|400px|'''Figure B: '''Spectral composite (RGB = NDVI,BI2,NDWI)]]
 
|}
 
|}
 
[[Category:Working with Raster Data]]
 
[[Category:Working with Raster Data]]
 +
[[Category:QGIS Tutorial]]
 +
[[Category:Tutorials]]

Latest revision as of 19:03, 14 June 2021

[edit] Spectral vegetation index using Raster Calculator

  • Click the Open Data Source Manager QGIS 3.0 datasource.png and then Add raster layer QGIS 2.0 addrast.png and select the file /geodata/lucc/s2/Subset_S2A_MSIL2A_20170619T_MUL.tif.
  • Check the rank and spectral range of bands in the multiband file (e.g. see table Changing Raster Layer Style). Here the rank of 10 bands is B2,B3,B4,B5,B6,B7,B8,B8A,B11,B12.
  • Click Raster --> Raster calculator.
  • A powerful normalization is realized by the normalized difference vegetation index that forms the basis of most vegetation indices $NDVI = (Nir - Red) / (Nir + Red)$. It can be implemented using Raster Calculator as seen in the following screenshot:

Qgis raster calc ndvi.png

  • Define path and file name of the output layer. OK.
  • Map visualization: Open the raster layer properties by right-clicking the ndvi raster in the TOC selecting Properties, or by simply double clicking.
  • Select the Symbology tab. Under Render type select Singleband pseudocolor.
    • Open the the pulldown menu of Color ramp by clicking on Qgis pull down.png Select All color ramps --> RdYlGn. Under Mode select Equal interval. Set the number of Classes to 10. In the pulldown menu of Color ramp select Invert Color Ramp.
    • To finish, click Apply (see Fig. A).

[edit] Several spectral indices at once using OTB

A convenient module for calculating one or several spectral indices at the same time can be found in the QGIS processing toolbox.

  • Type Radiometric into the search field and find the OTB --> Feature Extraction --> Radiometric Indices tool.
  • Open it with a double click.
  • Assign the bands in the multiband file to the correct spectral sensitivity.
  • If you want to calculate a single spectral index type in the text field Available Radiometric Indices: "Vegetation:NDVI"
  • If you want to calculate several spectral indices at once and store them in a multiband file click Help to find definitions of available spectral indices in three categories (vegetation, soil, water) and relevant channels of the input multiband image.
  • In the text field Available Radiometric Indices type with apostrophs:

"Vegetation:NDVI Water:NDWI2 Soil:BI2"

  • Click Run.
Qgis radiometric composite.png


Figure A: Single band NDVI (color table = RdYlGn)
Figure B: Spectral composite (RGB = NDVI,BI2,NDWI)
Personal tools
Namespaces

Variants
Actions
Navigation
Development
Toolbox
Print/export