Products QGIS Scripts Raster Threshold Mask
Raster Threshold Mask

QGIS Script · Python

Raster Threshold Mask

Creates a filtered raster where only pixels above or below your threshold are retained — everything else becomes transparent NoData. Set a threshold of 0.4 on an NDVI raster and only healthy vegetation pixels survive.

$20 USD One-time purchase · Instant download
Buy on Gumroad

What you get

raster_mask_generator.py
Free updates via Gumroad

What it does

Greater-than or less-than modes

Keep pixels above the threshold (e.g. NDVI > 0.4 for healthy vegetation) or below it (e.g. elevation < 850 m for low-lying zones).

Any single-band raster

Works with NDVI, elevation, CHM, or any single-band raster loaded into QGIS — not limited to specific layer types.

NoData masking

Filtered-out pixels are set to NoData (transparent in QGIS), making the masked raster easy to overlay on other layers.

Configurable nodata value

Set nodata to None (NaN), -9999, or any value — useful for compatibility with downstream GIS tools.

How to use it

  1. 1

    Load your raster (NDVI, CHM, elevation, etc.) into QGIS and check (tick) it in the Layers panel.

  2. 2

    Open Plugins → Python Console → Show Editor.

  3. 3

    Paste the script. At the bottom set threshold (numeric cutoff), comparison ("greater_than" or "less_than"), and optionally nodata.

  4. 4

    Click Run.

Requirements

  • QGIS 3.28 or newer
  • QGIS processing framework — bundled
  • First checked raster layer in the Layers panel

Also in the Vegetation & Field Analysis Pack

Get all 6 vegetation scripts for $40 — save $20 vs buying individually.

View bundle