4. Band Math: Mapping Vegetation#
Goal: compute a vegetation index over the campus scene, display it, and read the result as a canopy map.
Data: caltech_4_100_150_nm.hdr (from Tutorial 1).
Reference: Band Math, Display and Contrast Stretch.
The idea#
Tutorial 3 showed the canopy spectrum dropping at 702 nm and climbing at 852 nm while roofs and asphalt stayed flat. A normalized difference turns that contrast into one number per pixel:
Dividing by the sum normalizes out brightness, so a shadowed leaf and a sunlit leaf score alike. Values run −1 to +1: dense green vegetation high, bare soil and pavement near zero, water below zero.
A note on which “red” you have
Standard NDVI uses a red band near 670 nm, at the bottom of the chlorophyll absorption. The reddest band in this cube is 702 nm, on the shoulder of the red edge where a leaf is already brightening. Substituting it gives a red-edge NDVI: absolute values come out lower than a 670 nm NDVI would, and it saturates differently over dense canopy. It separates vegetation from everything else just as cleanly, which is what you want here. Do not compare these numbers against published 670 nm NDVI values, though.
Choose bands by what they physically measure, not by what an index is conventionally called.
Step 1 — Write the expression#
Open the campus scene as in Tutorial 1.
Choose Tools ▸ Band math…. The Band Math dialog opens.
In the Expression: box at the top, type:
(nir - red) / (nir + red)
Press Enter on your keyboard, or click elsewhere in the dialog. WISER parses what you typed and adds a row under Variable bindings: for every name it does not recognize as a function — here,
nirandred.
Step 2 — Bind the variables#
The Variable bindings: table has three columns: Variable (the name from your expression), Type (what kind of thing it binds to), and Variable Assignments (which dataset and band).
Check that Type reads Image Band for both rows. That is the default.
Scroll right in the table to reach the Variable Assignments column, which holds three dropdowns per row: the dataset, how the band is picked (Band or Wavelength), then the band within it. Leave the middle one on Band.
In the
nirrow, set the dataset tocaltech_4_100_150_nmand the band to Band 3: 852.68 nm.In the
redrow, set the same dataset and Band 2: 702.42 nm.Type
NDVIinto Result name (optional): near the bottom. Without a name the result is harder to find in the dataset list later.Click OK. After a moment the result is added as a new dataset named NDVI.
Two other parts of the Band Math dialog are worth knowing:
To the right of the Expression: box, WISER reports the result type and size —
Result: Image Band 150x150 (87.9KB). Band math is not streamed for every case, so check this before running an expression on a full flight line.Toggle Help opens the operator reference in a panel on the right. Read it, because the built-in function set is deliberately small.
Step 3 — Display it meaningfully#
A diverging colormap such as RdYlGn shows low values in red, middle values in yellow and high values in green, which makes vegetation stand out far more than gray levels do.
Use the Select dataset to view dropdown on the Main Toolbar to switch the main window to the new NDVI dataset. It is drawn in grayscale, and the Spectrum Plot will no longer plot a spectrum for the pixels you click, because NDVI has only one band.
Click Band chooser on the Main Toolbar. Select Grayscale in the General section, set Grayscale Band to band 0, tick Use a colormap, choose RdYlGn from the dropdown, and click OK.
Click Stretch builder, select Linear Stretch, click 2.5% linear, and click OK.
Interpretation
Every street tree resolves as an individual green crown, the hedgerows show as continuous green lines, and the lawn in the south-east as a solid block. Roofs, roads and parking areas render red to orange; only vegetation reaches yellow-green and green. The index has separated the vegetation from everything else using two bands, where the true-color image needed you to recognize shapes.
Note
Set the stretch on any computed product before you read it. Index values have no reason to fill the display range sensibly, and a single extreme pixel at a scene edge can flatten everything else into one color. Check the histogram in the stretch dialog first.
Step 4 — Compare side by side#
Click Split/unsplit the main view on the Main Toolbar, the grid button, and choose 1 row x 2 columns from its menu. The main window splits in two.
Use the Select dataset to view dropdown above the left panel to show
caltech_4_100_150_nm, and the one above the right panel to showNDVI.Click Link view scrolling on the Main Toolbar.
Pan or zoom one panel and the others follow. The status bar confirms with
Linked view scrolling is ON. Linked scrolling works when the displayed
datasets overlap on the ground, or have the same width and height, as these
two do.
Note
In grid view the band chooser and contrast stretch controls move from the Main Toolbar to a strip above each panel, so you can set them per panel.
Step 5 — Threshold it#
To go from a continuous index to a canopy mask, run one more expression:
ndvi > 0.35
Open Tools ▸ Band math… again, type the expression, and bind ndvi as an
Image Band pointing at band 0 of the NDVI dataset. Comparison operators
return 1 where the test passes and 0 where it fails, so the result is a binary
canopy mask you can count, export, or use to restrict another analysis.
Pick the threshold from your own data rather than from a paper. With the NDVI dataset on screen, click a few pixels you know are canopy and a few you know are pavement, and read each one’s Val: in the status bar. Cut between the two groups.
What band math can and cannot do#
The built-in function set is small: there is no sqrt, log or exp. Use
** 0.5 for a square root; for anything else a
band-math plugin adds functions
without rebuilding WISER. Variables can also bind to a whole image cube or to a
spectrum, and Enable Batch Processing applies one expression across every
raster in a folder. The operator list and every option are in
Band Math.
What you can now do#
Write and bind a band-math expression
Choose bands on physical grounds and say what that choice costs
Display an index with a diverging colormap and a percent stretch
Compare two datasets in a linked grid
Threshold a continuous index into a mask
Next: Tutorial 5 — Classifying a Scene — let the data find its own classes.