Raster Operator Calculator
Example Data Table
| Use Case | Expression Pattern | Operator Type | Sample Meaning |
|---|---|---|---|
| Band sum | "band_a@1" + "band_b@1" | Arithmetic | Adds two raster cell values. |
| Threshold mask | "dem@1" > 1000 | Comparison | Finds cells above elevation limit. |
| Ratio index | ("nir@1" - "red@1") / ("nir@1" + "red@1") | Composite | Creates an NDVI style index. |
| Boolean test | ("slope@1" > 15) AND ("rain@1" > 80) | Logical | Combines two conditions. |
Formula Used
The main formula depends on the selected operator.
Arithmetic: Output = A operator B.
Scaled output: Final Output = Raw Result × Scale + Offset.
Threshold test: Pass = Final Output ≥ Threshold.
NDVI style ratio: Output = (A - B) / (A + B).
NoData rule: When enabled, any input matching NoData returns NoData.
How to Use This Calculator
- Enter both raster band names as they appear in your project.
- Add sample cell values from two matching raster cells.
- Select a valid operator or a common raster formula preset.
- Set NoData, scale, offset, and threshold options.
- Press Calculate to view the result below the header.
- Use CSV or PDF download for records and reports.
Understanding QGIS3 Raster Calculator Operators
What This Tool Checks
Raster math can look simple, but small syntax mistakes create bad layers. This calculator helps you test common operators before building an expression. It uses two sample cell values. Then it applies the selected rule. The result shows the likely output for one raster location. This makes planning easier before processing a full dataset.
Valid Operator Groups
QGIS raster expressions often use arithmetic, comparison, and logical operators. Arithmetic operators include addition, subtraction, multiplication, division, and powers. Comparison operators test values against limits. They are useful for masks, classes, and filtering. Logical operators combine conditions. They help create suitability models and rule based outputs.
Raster Band References
A raster band is usually referenced by layer name and band number. The band name should be quoted in expressions. A common pattern is "layer@1". When names contain spaces, quoting becomes even more important. This calculator lets you type custom names. The expression preview then shows a clean formula pattern.
NoData and Division Safety
NoData values need careful handling. A cell may look numeric but still represent missing information. This tool can return NoData when either input matches your chosen value. Division also needs a safety check. A denominator of zero cannot produce a valid raster value. The calculator reports that case clearly.
Advanced Planning
Use the scale and offset fields for adjusted outputs. These are helpful when values need unit conversion. The threshold field gives a quick pass or fail check. This supports classification and mask planning. The NDVI preset shows how compound expressions work. It uses two bands in one formula. You can adapt the same idea for moisture, burn, or ratio indexes.
Practical Advice
Always confirm raster alignment before final processing. Cell size, extent, and projection should match. Also test a few known pixel values. This prevents silent errors in map algebra. Use this calculator as a planning aid. Then copy the expression pattern into your GIS workflow. Review outputs visually after processing. Save results with clear names and documented assumptions.
FAQs
1. What operators are commonly used in QGIS3 raster calculations?
Common operators include +, -, *, /, ^, comparisons, and logical tests. They support cell by cell math, masks, ratios, and classification expressions.
2. Can I use comparison operators with raster bands?
Yes. Comparison operators can test each cell against another band or number. They are useful for creating binary masks and threshold layers.
3. Why does division by zero matter?
Division by zero creates an invalid result. Raster ratios should be checked carefully, especially when the denominator can become zero.
4. What is a NoData value?
NoData represents missing or ignored cells. It should not be treated like normal measured data during analysis.
5. What does the NDVI preset calculate?
It calculates a ratio using (A - B) / (A + B). It is commonly adapted for vegetation and other band index workflows.
6. Should raster band names be quoted?
Quoting band names is safer. It helps prevent syntax issues when layer names contain spaces, symbols, or band references.
7. Can this tool process real raster files?
No. It tests sample values and expression logic. Use your GIS software to run the final raster calculation on actual layers.
8. Why use scale and offset fields?
Scale and offset help adjust raw results. They are useful for unit conversion, calibration, and preparing values for reports.