Skip to content
← Back to QGIS from first project to capstone
QGIS · Part 12 of 20Intermediate· 6 min readSources

QGIS Raster Analysis: Reclassification, Raster Overlay, Zonal and Local Statistics

Reclassify an NDVI raster into classes, combine rasters with the raster calculator, summarise values inside polygons with zonal statistics, and compare dates with local statistics.

Data used

  • NDVI for 15 March 2025 and 14 March 2020, made with the formula from Part 8 (ndvi_2025.tif, ndvi_2020.tif). Calculate both from the Sentinel-2 tile 43PGQ, using the same bands and the same scale and offset.
  • parks and lakes polygons from Q11.

Both NDVI rasters must share the same extent, cell size and CRS, or the local statistics will fail. Sentinel-2 tiles from the same MGRS tile do.

1. Reclassify

Reclassification replaces ranges of cell values with new class codes. It turns a continuous raster into something you can map, count and compare.

Choose the classes

Use thresholds you can justify. The histogram helps, and so does checking against imagery. For this scene, one possible scheme is below. Treat the breaks as a starting point, and check them against the true-colour image.

NDVI rangeClassCode
Below 0.1Water, built-up and bare ground1
0.1 to below 0.3Sparse vegetation2
0.3 to below 0.5Moderate vegetation3
0.5 and aboveDense vegetation4

Run the tool

  1. Processing Toolbox > Reclassify by Table.
  2. Raster layer: ndvi_2025. Band: 1.
  3. Click the ... next to Reclassification table, then Add Row for each class. Fill Minimum, Maximum and Value.
  4. Range boundaries: choose min < value <= max or min <= value < max, so each cell falls in exactly one class.
  5. Output data type: Byte is enough for class codes.
  6. Run, and style the result with Paletted/Unique values.
Reclassification table filled in
Figure 12.1. Reclassification table filled in
Four-class vegetation map
Figure 12.2. Four-class vegetation map

Alternatives: Reclassify by Layer (read the table from a layer), or the Raster Calculator with a conditional expression.

("ndvi_2025@1" < 0.1) * 1 +
(("ndvi_2025@1" >= 0.1) AND ("ndvi_2025@1" < 0.3)) * 2 +
(("ndvi_2025@1" >= 0.3) AND ("ndvi_2025@1" < 0.5)) * 3 +
("ndvi_2025@1" >= 0.5) * 4

Each test returns 1 or 0, and multiplying by the class code adds up to a single class value per cell.

2. Class areas

Processing > Raster Layer Unique Values Report counts cells in each class.

  1. Input layer: the reclassified raster.
  2. Run. The report gives the cell count and area for each value.
  3. Area is in the layer's units. In EPSG:32643 with 10 m cells, one cell covers 100 square metres, so 10,000 cells make 100 hectares.

Open the HTML report, or save the table as CSV.

3. Raster overlay

Raster overlay combines layers cell by cell using map algebra. Cells that line up are combined, so layers must share a grid.

Boolean overlay: vegetation that was lost

  1. Make two masks with the Raster Calculator: "ndvi_2020@1" >= 0.5 and "ndvi_2025@1" >= 0.5.
  2. Combine them to find cells that were dense in 2020 and are not in 2025:
("mask_2020@1" = 1) AND ("mask_2025@1" = 0)
  1. Style the result in red, with 0 transparent.
Cells that lost dense vegetation between 2020 and 2025
Figure 12.3. Cells that lost dense vegetation between 2020 and 2025

Weighted overlay

A weighted overlay multiplies each layer by a weight and sums them. It is the basis of the suitability analysis in Q15.

0.5 * "slope_score@1" + 0.3 * "road_score@1" + 0.2 * "water_score@1"

The weights should add up to 1. Each input layer should be on the same scale, such as 1 to 5, before weighting.

Masking

To keep values only inside a class or polygon, multiply by a 0 and 1 mask, or use Clip Raster by Mask Layer. For example, to see NDVI only on parks, clip ndvi_2025 by parks.

4. Zonal statistics

Zonal statistics summarise a raster inside each polygon, such as mean NDVI for each park.

  1. Processing Toolbox > Zonal Statistics.
  2. Input layer: parks. Raster layer: ndvi_2025. Raster band: 1.
  3. Output column prefix: ndvi25_.
  4. Statistics to calculate: Count, Mean, Median, Minimum, Maximum, Standard deviation.
  5. Run. The output layer has new columns, such as ndvi25_mean.
  6. Repeat with ndvi_2020 and the prefix ndvi20_.
  7. In the Field Calculator, create ndvi_change as "ndvi25_mean" - "ndvi20_mean".
Parks coloured by mean NDVI
Figure 12.4. Parks coloured by mean NDVI
Attribute table with the zonal statistics columns
Figure 12.5. Attribute table with the zonal statistics columns

For counts per class within each polygon, use Zonal Histogram on the reclassified raster. It adds a column for each class code.

5. Local statistics

Local statistics work cell by cell across several rasters. This is the reverse of zonal statistics, which works within zones.

  1. Processing Toolbox > Cell Statistics.
  2. Input layers: ndvi_2020 and ndvi_2025 (add more dates if you have them).
  3. Statistic: Mean, then Run again for Maximum, Minimum, Range, Standard deviation or Sum.
  4. Reference layer: choose one of the inputs so the output matches its grid.
  5. Tick Ignore NoData values if some dates have gaps.

The result shows, for example, the mean NDVI for each cell across all dates. A high standard deviation marks cells that changed a lot.

Cell Statistics dialog and mean NDVI output
Figure 12.6. Cell Statistics dialog and mean NDVI output

Other raster tools to know

TaskTool
Summary of a whole rasterRaster Layer Statistics
Values at point locationsSample Raster Values
Match cell size and extentAlign Rasters
Convert values between data typesTranslate (Convert Format)
Mask to the strongest classRaster Calculator with a conditional

Common mistakes

  • Using class breaks from a textbook without looking at the histogram.
  • Overlaying rasters of different extent or cell size without aligning them first.
  • Forgetting NoData in map algebra. A NoData cell in any input becomes NoData in the output.
  • Using different scale factors on two NDVI dates.
  • Trusting the mean of a polygon that has only a few cells.
  • Reading the area from the wrong units.

Key takeaways