QGIS Raster Calculator Tutorial: Math, Band Combinations and Custom Indices
- Primary Signal: QGIS Raster Calculator Tutorial: Math, Band Combinations and Custom Indices
- Overview: The QGIS Raster Calculator turns ordinary bands into custom indices, masks and classifications. Learn the syntax, the common band combinations, and how to build your own index from...
- Verification: Analyzed and compiled by FreeSky GeoData editorial monitoring desk.
The Raster Calculator is one of the most useful tools in QGIS, and one of the most underused. It lets you write a mathematical expression over raster bands and produce a new raster, which means you can build vegetation indices, combine bands, mask out clouds and reclassify values without leaving QGIS.
Open it from the Raster menu, and you will see a list of the bands in your loaded rasters, each with a name like landsat8@1. Double-click a band to add it to the expression box, then use the operator buttons or type the maths directly. A simple NDVI, for example, is (NIR minus Red) divided by (NIR plus Red), written with the band names for your own imagery. The calculator evaluates the expression cell by cell across the whole raster.
The most common uses are band combinations and indices. Natural colour uses red, green and blue. False colour infrared swaps in the near-infrared band, turning healthy vegetation bright red. NDVI measures vegetation health, NDWI measures water, and NDBI highlights built-up areas. Each index is a ratio of two bands, and the calculator makes it a one-line expression.
Conditional expressions are where the tool earns its keep. You can write an expression that returns 1 where a condition is true and 0 elsewhere, which gives you a mask: water equals 1, land equals 0, or cloud equals 1, clear equals 0. Chain conditions together and you can build a simple classification, such as vegetation, bare soil and water, from thresholds on an index.
Watch out for three common mistakes. First, make sure your bands share the same extent, resolution and coordinate reference system, or the output will be wrong. Second, remember that the calculator works on the raw values, so check whether your data needs scaling, for example Sentinel-2 values divided by 10,000. Third, set the output data type deliberately: a floating-point result stored as an integer will lose its decimals. Save the expression as a named formula if you reuse it, and keep a note of which bands you used, because a formula is only reproducible if the inputs are recorded.
📖 Continue Reading the Full Story
Continue reading this article on FreeSky GeoData.
⚡ Access Full Content Now