Raster Calculator Expressions GIS: 5 Essential Formulas

Raster Calculator Expressions GIS: 5 Essential Formulas

In spatial analysis and remote sensing lab assignments, grid-based cell manipulation is a foundational skill. Mastering raster calculator expressions GIS syntax allows you to run complex Map Algebra operations—ranging from spectral band math and unit conversions to multi-criteria land suitability modeling.
However, students frequently run into syntax errors, incorrect boolean logic operators, or unexpected NoData outputs when entering expressions in desktop GIS tools. This tutorial provides a developer-friendly reference guide covering five essential Map Algebra formulas, detailing exact syntax rules for both QGIS and ArcGIS Pro.

Quick Navigation / Table of Contents

  1. Core Concepts: Map Algebra Operators & Data Types
  2. 5 Essential Raster Calculator Expressions GIS Formulas
    • Formula 1: Normalized Difference Vegetation Index (NDVI)
    • Formula 2: Conditional Masking (Con / IF)
    • Formula 3: Unit Conversions (Elevation & Temperature)
    • Formula 4: Multi-Criteria Binary Overlay Modeling
    • Formula 5: Replacing NoData Pixels with Constant Values
  3. Software Comparison: QGIS vs. ArcGIS Pro Syntax Rules
  4. Pro Tip: Managing Spatial Resolution, Extents, and Cell Alignment
  5. Frequently Asked Questions (FAQ)
  6. Conclusion & Syntax Reference Summary

1. Fundamentals of Map Algebra in GIS

Map Algebra is the mathematical language used to manipulate geographic raster grids. Operations process datasets on a cell-by-cell basis across aligned layers.
+-------------------------------------------------------------------------+
|                        INPUT RASTER GRID LAYERS                         |
|             Aligned Cell Grids (Band 4, Band 5, DEM, Land Cover)        |
+------------------------------------+------------------------------------+
                                     |
                                     v
                  +-------------------------------------+
                  |      MAP ALGEBRA EXPRESSION ENGINE  |
                  |  Mathematical, Relational, Logical  |
                  +------------------+------------------+
                                     |
            +------------------------+------------------------+
            |                                                 |
            v                                                 v
  [ Arithmetic Operators ]    [ Relational Operators ]     [ Logical / Conditional ]
  + , - , * , / , ^           > , < , == , >= , <= , !=   AND (&) , OR (|) , Con / IF
Master raster calculator expressions gis formulas in QGIS and ArcGIS Pro. Learn Map Algebra syntax for land suitability, masking, and NDVI.

Map Algebra Category Breakdown

  • Arithmetic Operations: Basic math functions calculated cell-by-cell ($+$, $-$, $*$, $/$).
  • Relational Operations: Comparative evaluations that return boolean values ($1$ for True, $0$ for False).
  • Logical Operations: Combine multiple criteria using boolean operators (AND, OR, NOT).
  • Conditional Statements: Evaluate conditions per cell and assign dynamic output values based on whether the statement evaluates to True or False.

2. 5 Essential Raster Calculator Expressions GIS Formulas

Formula 1: Normalized Difference Vegetation Index (NDVI)

NDVI quantifies vegetation health by measuring the difference between Near-Infrared (NIR) light (which healthy vegetation strongly reflects) and Red light (which vegetation absorbs).
raster calculator expressions gis ndvi formula

Mathematical Formula

$$\text{NDVI} = \frac{\text{NIR} – \text{Red}}{\text{NIR} + \text{Red}}$$

Expression Syntax

  • ArcGIS Pro (Raster Calculator / Spatial Analyst):

    Python

    (Float("Landsat8_B5.tif") - Float("Landsat8_B4.tif")) / (Float("Landsat8_B5.tif") + Float("Landsat8_B4.tif"))
    
  • QGIS (Raster Calculator):

    SQL

    ("Landsat8_B5@1" - "Landsat8_B4@1") / ("Landsat8_B5@1" + "Landsat8_B4@1")
    
Syntax Note: In ArcGIS Pro, integer rasters perform integer division by default. Wrapping band variables in the Float() function ensures floating-point calculations with decimal values between -1.0 and +1.0.

Formula 2: Conditional Statements for Suitability Masking

Conditional logic allows you to isolate pixels that meet specific criteria when building raster calculator expressions gis models.

Scenario

Select elevation pixels higher than 1,500 meters and assign them a value of 1. Reassign all lower elevations to 0.

Expression Syntax

  • ArcGIS Pro (Con Tool / Map Algebra):

    Python

    Con("DEM_Meters.tif" > 1500, 1, 0)
    
  • QGIS (IF Statement):

    SQL

    if("DEM_Meters@1" > 1500, 1, 0)
    

Formula 3: Unit Conversions

Lab assignments often require converting measurement units across spatial datasets using simple raster calculator expressions gis syntax.

Elevation: Convert Meters to Feet

$$\text{Feet} = \text{Meters} \times 3.28084$$
  • ArcGIS Pro:

    Python

    "Elevation_m.tif" * 3.28084
    
  • QGIS:

    SQL

    "Elevation_m@1" * 3.28084
    

Temperature: Convert Celsius to Fahrenheit

$$\text{Fahrenheit} = (\text{Celsius} \times 1.8) + 32$$
  • ArcGIS Pro:

    Python

    ("Temp_Celsius.tif" * 1.8) + 32
    
  • QGIS:

    SQL

    ("Temp_Celsius@1" * 1.8) + 32
    

Formula 4: Combining Multi-Criteria Layers into Binary Suitability Maps

Syntax errors usually stem from missing parentheses or incorrect boolean operators when constructing raster calculator expressions gis statements.

Scenario

Identify suitable construction sites that satisfy three conditions:
  1. Slope is less than 10 degrees.
  2. Distance to roads is less than 500 meters.
  3. Land cover category equals 5 (cleared grassland).

Expression Syntax

  • ArcGIS Pro (Python Bitwise Syntax):

    Python

    ("Slope.tif" < 10) & ("Road_Distance.tif" < 500) & ("LandCover.tif" == 5)
    
  • QGIS (Relational Logical Syntax):

    SQL

    ("Slope@1" < 10) AND ("Road_Distance@1" < 500) AND ("LandCover@1" = 5)
    
Result: Cells that satisfy all three criteria evaluate to 1 (Suitable), while all other cells return 0 (Unsuitable). For details on weighted overlay models, see our article on For details on weighted overlay models, see our article on [Multi Criteria Evaluation GIS Guide]

Formula 5: Replacing NoData Values with Zero

When combining rasters using addition or multiplication, any pixel intersecting a NoData cell evaluates to NoData. Replacing null values with zero prevents dataset gaps during overlay modeling.

Expression Syntax

  • ArcGIS Pro (IsNull + Con):

    Python

    Con(IsNull("Precipitation.tif"), 0, "Precipitation.tif")
    
  • QGIS (NO_DATA Null Clause):

    SQL

    if("Precipitation@1" IS NULL, 0, "Precipitation@1")
    

Pro Tip: Preventing Spatial Alignment & Grid Mismatch Errors

Executing raster calculations on layers with mismatched cell sizes, extent boundaries, or coordinate systems can lead to misaligned grid outputs or distorted results.
Best Practices Before Executing Expressions:
  1. Environments & Extents: In ArcGIS Pro, open Environments in the Geoprocessing Pane and set Extent and Snap Raster to your primary study area layer.
  2. Reproject Layers: Ensure all input rasters share the exact same Projected Coordinate System (PCS) before entering expressions.
  3. Match Spatial Resolution: Use the Resample tool to standardize pixel resolutions (e.g., matching a 10m Sentinel band to a 30m DEM) prior to running complex map algebra.
For full expression documentation and built-in functions, consult the official QGIS Raster Calculator Syntax Documentation.

3. Software Comparison: QGIS vs. ArcGIS Pro Syntax Rules

Syntax Feature QGIS Raster Calculator ArcGIS Pro Raster Calculator
Layer Variables Enclosed in double quotes with band suffix: "Layer@1" Enclosed in quotes or referenced as layer objects: "Layer.tif"
Equality Operator Single equals sign: = Double equals sign: ==
Conditional Function if(condition, true_value, false_value) Con(condition, true_value, false_value)
Logical AND Written word: AND Bitwise ampersand: &
Logical OR Written word: OR Bitwise pipe: `
Null Value Test layer IS NULL IsNull(layer)

4. Frequently Asked Questions (FAQ)

Why am I getting a syntax error in my Map Algebra expression?

Syntax errors usually stem from missing parentheses, using a single equals (=) instead of a double equals (==) in ArcGIS Pro, forgetting Float() conversions during integer division, or missing double quotes around layer names.

How do I write a conditional IF statement in QGIS Raster Calculator?

In QGIS, use the syntax structure if(condition, value_if_true, value_if_false). For example, if("DEM@1" > 500, 1, 0) assigns 1 to elevation cells over 500 meters and 0 to all other cells.

Why does my raster output result in all 0s or NoData?

Outputs evaluate entirely to 0 or NoData when input layers do not spatially overlap, when coordinate systems are mismatched, or when boolean statements contain mutually exclusive conditions (e.g., value > 10 AND value < 5).

5. Conclusion & Summary

Mastering raster calculator expressions GIS syntax is a crucial step toward executing advanced spatial modeling, remote sensing index calculations, and site suitability workflows. By following platform-specific syntax rules, handling NoData values cleanly, and standardizing layer projections before processing, you can execute error-free Map Algebra operations in any lab assignment.
Key Takeaways:
  • Use Float() in ArcGIS Pro to enforce decimal outputs during division.
  • Match conditional functions to your software: Con() in ArcGIS Pro vs. if() in QGIS.
  • Use double equals (==) for equality tests in ArcGIS Pro and single equals (=) in QGIS.
  • Verify layer extents, pixel resolutions, and coordinate systems before running calculations.