# 2 - Generate NDVI ```{container} algorithm-id **Algorithm ID**: `hedgetools:generatendvi` ``` This tool generates a vegetation raster using the Normalized Difference Vegetation Index (NDVI). It is computed from an infrared band and a red band. The NDVI (Normalized Difference Vegetation Index) represents vegetation density and health, calculated from the red and infrared bands. Higher values indicate denser, healthier vegetation. The binary mask or the sieved mask will be used to generate the tree cover layer in [Generate Tree Cover](./generate_tc.md). The NDVI output can be used to generate additional binary masks with the [Raster Calculator](https://docs.qgis.org/3.40/en/docs/user_manual/processing_algs/gdal/rastermiscellaneous.html#raster-calculator) ## Parameters | Label | Name | Type | Description | |-------|------|------|-------------| | Input Red raster | `RED` | [raster] | Red raster | | Red band | `RED_BAND` | [raster band]
Default: 1 | Band of the Red raster to use in case of multiband. | | Input Infrared raster | `INFRARED` | [raster] | Infrared raster | | Infrared band | `INFRARED_BAND` | [raster band]
Default: 1 | Band of the Infrared raster to use in case of multiband. | | Extent of the study area
Optional | `EXTENT` | [extent] | Input extent from a layer, canvas, or other source to clip the rasters. | | NDVI value threshold (NDVI mask)
Optional | `THRESHOLD_MASK` | [numeric: double]
Default: 0.20 | Threshold to create the binary NDVI mask. Pixels above this value are considered vegetation. | | Compute sieved NDVI mask | `SIEVE` | [boolean]
Default: True | If enabled, the NDVI mask is sieved to remove small holes. Recommended to reduce noise in vegetation layers. | | Threshold sieve value (pixel number) | `THRESHOLD_SIEVE` | [numeric: integer]
Default: 100 | Minimum number of pixels for a feature to be kept in the sieved mask. | | Handling of extent differences | `EXTENT_OPT` | [enumeration]
Default: 0 | Determines how the tool handles differing DSM and DTM extents: | | Output resolution (meters)
Optional | `RESOLUTION` | [numeric: double]
Default: `[same as input]` | Change the output raster resolution to the desired value. | | Resampling method
Optional | `RESAMPLING` | [enumeration]
Optional
Default: 0 | Resampling method for output resolution: | | Output NDVI | `OUTPUT_NDVI` | [raster]
Default: `[Create temporary layer]` | Output raster. | | Output mask | `OUTPUT_MASK` | [raster]
Default: `[Create temporary layer]` | Output raster. | | Output sieve | `OUTPUT_SIEVE` | [raster]
Default: `[Create temporary layer]` | Output raster. | ```{admonition} Warning :class: warning The **NDVI value threshold** should be adjusted according to the acquisition date of your images. Typically, periods of lower vegetation activity require a lower threshold. ``` ```{admonition} Warning :class: warning The output resolution of your mask should match the resolution used in [Generate DHM](./generate_dhm.md). You can set this using the **Output Resolution** parameter. Typical resampling methods are **Average** for downsampling and **Nearest Neighbour** for upsampling. ``` ## Outputs | Label | Name | Type | Description | |-------|------|------|-------------| | Output NDVI | `OUTPUT_NDVI` | [raster] | NDVI raster representing vegetation. | | Output mask | `OUTPUT_MASK` | [raster] | Binary mask where pixels above the threshold are set to 1. | | Output sieve | `OUTPUT_SIEVE` | [raster] | Binary mask with small holes removed based on the sieve threshold. |