How to Calculate NDVI in QGIS With Sentinel-2: Step-by-Step Guide
- Primary Signal: How to Calculate NDVI in QGIS With Sentinel-2: Step-by-Step Guide
- Overview: NDVI measures vegetation health from satellite data, and it takes five minutes to calculate in QGIS. This step-by-step guide uses free Sentinel-2 imagery and the Raster Calculator....
- Verification: Analyzed and compiled by FreeSky GeoData editorial monitoring desk.
NDVI, the Normalized Difference Vegetation Index, is the most-used remote sensing metric in the world, and it takes about five minutes to calculate in QGIS. It measures vegetation health by comparing how much near-infrared light a surface reflects against how much red light it reflects, and the result is a single number between -1 and +1 for every pixel. Healthy green vegetation scores high, bare soil scores low, and water scores below zero. This guide walks through the calculation step by step with Sentinel-2 data, the most common free source, and shows you how to read the result.
What NDVI Actually Measures
Healthy leaves absorb red light for photosynthesis and reflect near-infrared light strongly, because the spongy tissue inside the leaf scatters it. Stressed, sparse or dead vegetation reflects less near-infrared and more red, so the difference between the two bands is a reliable proxy for how much living, photosynthesizing vegetation is in each pixel. The formula is simple: NDVI equals near-infrared minus red, divided by near-infrared plus red. The result ranges from -1 to +1. Water and clouds score below zero, bare soil and rock score around 0 to 0.2, sparse vegetation scores 0.2 to 0.4, moderate vegetation scores 0.4 to 0.6, and dense, healthy vegetation scores above 0.6. Those thresholds are rules of thumb rather than laws, and they shift with the sensor, the season and the landscape, but they are a solid starting point for reading any NDVI map.
Getting Sentinel-2 Data
You need two bands: red and near-infrared. On Sentinel-2, red is Band 4 and near-infrared is Band 8, both at 10 metre resolution. The easiest way to get them is the Copernicus Browser, where you can search for a cloud-free scene over your area of interest and download the bands, or the Semi-Automatic Classification Plugin in QGIS, which can download Sentinel-2 tiles directly and stack them for you. Use Level-2A products if you can, because they are surface reflectance products that have already had atmospheric correction applied, which means the numbers you calculate are comparable across scenes and dates. Download the bands, unzip them, and load Band 4 and Band 8 into QGIS. Rename the layers to something short, such as S2_B04 and S2_B08, so the expressions stay readable.
Calculating NDVI in the QGIS Raster Calculator
Open QGIS and load the two bands as layers. Click the Band 8 layer in the Layers panel before opening the Raster Calculator, because the calculator takes its output extent, coordinate system and pixel dimensions from whichever layer is currently selected. Go to Raster, then Raster Calculator, and enter the expression with the band names in double quotes: ("B08@1" - "B04@1") / ("B08@1" + "B04@1"). The @1 means the first band of that layer. Check that the note under the expression box reads Expression valid, set the output layer to a GeoTIFF file, and run it. The calculation is fast: a 5 kilometre by 5 kilometre window of Sentinel-2 data at 10 metre resolution finishes in well under a second on a modern computer. The result is a continuous NDVI raster with values typically from about -0.5 to 0.95.
Styling and Reading the Result
Right-click the NDVI layer, go to Properties, then Symbology, and switch the render type to Singleband pseudocolor. Pick the RdYlGn colour ramp, red to yellow to green, set the minimum to 0 and the maximum to 0.9, and click Classify. Dense vegetation around fields and forests will show up in dark green, bare soil and roads in red, and water and dark spots will go negative. Build pyramids for large files, under Layer, Pyramids, Build, so the map stays snappy when you zoom. To define areas from specific NDVI values, use Reclassify by Table in the Processing Toolbox with the standard thresholds: below 0 for water and clouds, 0 to 0.2 for bare soil, 0.2 to 0.4 for sparse vegetation, 0.4 to 0.6 for moderate, and above 0.6 for dense. For a simple binary mask, such as only pixels above 0.5, use the Raster Calculator again with the expression NDVI@1 > 0.5, which returns 1 for matching pixels and 0 for the rest.
Common Mistakes and Next Steps
The most frequent error is using the wrong band numbers: near-infrared is Band 8 on Sentinel-2 but Band 5 on Landsat 8, and mixing them up gives nonsense. The second is forgetting the scale factor: Sentinel-2 Level-2A values are integers equal to 10,000 times the reflectance, and while a pure multiplier cancels out in a normalised difference, an offset in the data does not, so check the product metadata before processing. The third is ignoring clouds: use the Scene Classification Layer that comes with Sentinel-2 to mask cloudy pixels, or your NDVI will be full of false low values where clouds sit. Once you have a clean NDVI map, the natural next steps are calculating it for several dates to watch a crop grow through the season, computing zonal statistics per field parcel, and comparing NDVI with related indices such as EVI, SAVI and NDRE, which handle dense canopy and bare soil better. NDVI is the starting point, not the finish line, but it is a starting point you can reach in five minutes with free data and free software.