Tutorial: Landsat bands to NDVI and a water mask

Satellite → Remote sensing → Spectral indices… and Band cube (cut)… — the Tutorial button at the bottom of either dialog opens this page; the green ? beside it opens the reference for every field, the Remote sensing page.

This tutorial takes one Landsat 9 scene of the Lisbon region, on 2 July 2026, from its band files to a vegetation index (NDVI), a water mask, and a cube of the city and the Tagus estuary.

The data

The scene is LC09_L2SP_204033_20260702_20260703_02_T1: Landsat 9, path 204, row 033, Collection 2 Level-2 — surface reflectance, the product most people download. Get it from USGS EarthExplorer (https://earthexplorer.usgs.gov, a free account): search that ID under Landsat → Landsat Collection 2 Level-2 → Landsat 8-9 OLI/TIRS C2 L2, and from the product's options download the bands SRB2, SRB3, SRB4, SRB5 (blue, green, red, near infrared) and the MTL.txt, all into one folder.

A Level-2 band has had the atmosphere removed already: its numbers are codes for the surface reflectance, not the sensor's raw counts. Everything computed from it below is on surface reflectance; nothing here is a top-of-atmosphere quantity.

Stack the four bands with a .vrt — a small text file that lists them, nothing is copied — from Julia:

using GMT
cd("C:/landsat")       # the folder with the bands
b = ["LC09_L2SP_204033_20260702_20260703_02_T1_SR_B$k.TIF" for k in 2:5]
gdalbuildvrt(b, ["-separate"]; save = "lisbon_sr.vrt")

(or gdalbuildvrt -separate lisbon_sr.vrt …_SR_B2.TIF …_SR_B3.TIF …_SR_B4.TIF …_SR_B5.TIF in a terminal).

Example 1 — Open the stack

File → Open lisbon_sr.vrt. The window shows its first band, SR_B2. Its group in Scene Objects lists the four band files below the usual rows:

The .vrt's group lists its band files

Click one of them for Load file: that band opens in the window on its own, as File → Open would open it. Hover one for its full path.

Example 2 — NDVI, on surface reflectance

Open Satellite → Remote sensing → Spectral indices…. The File is the window's lisbon_sr.vrt, the Index is NDVI, and its two band slots are already filled: red with B4 (red) and nir with B5 (nir) — the file names tell which Landsat bands these are. The MTL is beside the bands, so Surface reflectance (from the MTL) is ticked: each band's codes are turned into surface reflectance (0–1) before the index is computed. The MTL says the scene is Level-2, and the box says so; on a Level-1 scene the same box reads Top of atmosphere reflectance.

NDVI, ready to compute

Press Compute. NDVI SR — lisbon_sr joins the window:

NDVI of the whole scene

  • the land is orange to dark red: vegetation, dry in early July except where it is watered or wooded; the dark red band running north-east is the farmland and woods along the Tagus valley;
  • water is green to deep blue (NDVI at or below 0): the inner Tagus estuary, the Sado estuary and the reservoirs inland. Over the open ocean the surface reflectance is close to 0 in both bands, and their ratio turns to speckle;
  • the white corners are outside the scene's swath: they have no data, and stay empty.

Example 3 — A water mask

In the same dialog, set Index to NDWI — Normalized difference water (McFeeters): its slots become green (B3 (green)) and nir (B5 (nir)). Set Output to Mask (≥ threshold) and Threshold to 0 — open water is where NDWI is positive.

A water mask, NDWI ≥ 0

Compute gives a black and white image, NDWI SR mask ≥ 0.0 — lisbon_sr, white where there is water:

Water in the scene

The ocean and both estuaries are one white body; inland the Tagus can be followed upstream, and the reservoirs stand out. The scene is almost cloud free (0.13 % in its MTL), so the sea is white throughout, but for a grey speckle off the Tróia coast where NDWI hovers just around 0.

Example 4 — A cube of Lisbon and the estuary

A whole scene is 7731 × 7841 pixels a band. Cut the four bands to a 40 × 40 km block around the estuary, into one file: open Satellite → Remote sensing → Band cube (cut)…. Opened over the .vrt, Band files already lists its four bands, all checked. Type the Region in the bands' own UTM metres — W 470000, E 510000, S 4270000, N 4310000 — and a Save as file:

Band cube over the .vrt

(Use the first band's extent fills the four boxes with the whole scene's limits, to trim by hand; Draw rectangle takes a rectangle drawn on the window now, Use last drawn rectangle one drawn before with Draw → Rectangle.)

Press Build cube. The cube opens in the window, and its group lists its four bands by name:

The cube's group lists its bands

Click a band for Load band: it joins the window as a layer of its own.

The cube keeps the scene's MTL in its metadata. In Spectral indices, point File at the cube and compute NDVI again — Surface reflectance is available, with no MTL file beside it, and the result is NDVI SR — lisbonsrcube:

NDVI of the cube

At 30 m the block shows the city's parks and woods (red — Monsanto is the large patch west of the centre) among the built-up land (yellow), the estuary's tidal flats and channels (green to blue), and, upstream in the north-east, the watered fields of the Tagus lezíria — centre pivots included.

Try next

  • Classes: NDVI with Output Classes (up to 3 separators) and 0.2, 0.4, 0.6 — bare, sparse, moderate and dense vegetation as four classes.
  • The other side of the mask: Mask (< threshold) with the same NDWI 0 gives the land.
  • One field only: Draw → Rectangle over the lezíria, then in Band cube Use last drawn rectangle and Build cube.
  • More bands: download SRB6 and SRB7 (SWIR) too and add them to the .vrt or the cube's file list. MNDWI (green, swir2) is the better water index where water lies next to built-up land; NBRI and NDMI need them as well.
  • Untick a band: in Band cube, untick the files you do not need — only the checked ones go into the cube — or drag them into another order.
  • One band's surface reflectance: Satellite → Remote sensing → Landsat calibration… on a band of this scene offers what a Level-2 band holds — surface reflectance, radiance at the surface and, for ST_B10, surface temperature.