Find a course

Module 4: Spatial AnalysisLesson 9 of 1115 min

Raster Analysis: Map Algebra, Terrain and Interpolation

Calculate with rasters using map algebra, derive slope from elevation models, compute NDVI from satellite bands and estimate surfaces by interpolation.

Step 1 of 12Learn

Map algebra: calculating cell by cell

Raster analysis treats each cell like a number in a spreadsheet, arranged on a grid. Map algebra, a term from geographer Dana Tomlin, describes calculations performed on rasters cell by cell.

Operations come in several types:

  • Local operations work on each cell independently, using values from one or more rasters at the same location. Converting elevation from feet to meters (multiply by 0.3048), adding two rainfall rasters, or finding cells where elevation > 1,000 AND land cover = forest.
  • Focal (neighborhood) operations use each cell and its neighbors, such as a 3 × 3 window. Smoothing a noisy image by averaging, or calculating slope from surrounding elevations.
  • Zonal operations summarize values within zones defined by another layer. Average elevation of each watershed, or total forest area per county.
  • Global operations use all cells, such as computing distance from every cell to the nearest road.

Rasters must align for local operations: same cell size, same extent and same CRS. Otherwise the software resamples one to match the other, which can introduce errors.

Reclassification is one of the most common raster tools: it replaces values or ranges with new ones. For example, slope values of 0–5% become 3 (good), 5–15% become 2 (fair) and over 15% become 1 (poor). Reclassified rasters can then be combined in a weighted overlay for suitability analysis, using the same idea as the vector approach but on a grid.

Step 2 of 12Practice · Sort into groups

Sort each raster operation by type.

Tap an item, then tap its group (or drag it there).

Step 3 of 12Diagram

Map algebra operations by reach

Map algebra operations by reachHierarchy diagram: Map algebra, Local, Focal, Zonal, Global.Map algebraLocalFocalZonalGlobal

Tap a shape with to see more.

Map algebra
Local

Each cell on its own: feet to meters, adding two rainfall rasters.

Focal

Each cell plus its neighbors: smoothing, slope.

Zonal

Summaries within zones: mean elevation per watershed.

Global

Uses every cell: distance to the nearest road.

Step 4 of 12Learn

Terrain analysis from elevation models

A digital elevation model (DEM) stores elevation in each cell, and from it GIS can derive many terrain products.

Slope measures steepness. It can be expressed as:

  • Percent slope = rise ÷ run × 100. A rise of 10 m over 100 m horizontal distance is a 10% slope.
  • Degrees = arctan(rise ÷ run). A 10% slope is about 5.7°; a 100% slope is 45°.

Slope matters for construction (many building codes limit slopes), agriculture (erosion risk), landslides and accessibility.

Aspect is the compass direction a slope faces, from 0° (north) through 90° (east), 180° (south) and 270° (west). In the Northern Hemisphere, south-facing slopes receive more sun, which affects vegetation, snowmelt and solar panel siting.

Hillshade simulates light falling on the terrain from a chosen direction, creating a shaded-relief image that makes landforms easy to see. It is often placed beneath other layers with some transparency.

Hydrological analysis uses flow direction and flow accumulation to trace where water would flow, delineate watersheds (all the land draining to a point), and generate stream networks from a DEM.

Viewshed analysis finds all cells visible from a point, used for siting cell towers, wind turbines or observation posts.

The quality of all these products depends on the DEM's resolution and accuracy. Lidar-derived DEMs at 1 m resolution reveal ditches and small ridges invisible in 30 m global DEMs.

Step 5 of 12Note

Step 6 of 12Try the calculator

Slope from rise and run

Enter the elevation change and horizontal distance between two points to get slope in percent and degrees.

Slope
12.5 %
Slope
7.1 °

Step 7 of 12Practice · Work it out

Two points are 200 m apart horizontally and differ in elevation by 30 m. What is the slope in percent?

Step 8 of 12Learn

NDVI and interpolation

NDVI, the Normalized Difference Vegetation Index, is a classic raster calculation from satellite imagery. Healthy green plants absorb most red light (for photosynthesis) and strongly reflect near-infrared (NIR) light. NDVI exploits this:

NDVI = (NIR − Red) ÷ (NIR + Red)

Values range from −1 to +1. Water and clouds usually give negative values; bare soil and rock give values near 0 to about 0.2; sparse or stressed vegetation roughly 0.2 to 0.5; dense, healthy vegetation 0.6 and above. Farmers use NDVI maps to spot stressed areas in fields; scientists use NDVI time series to track droughts, deforestation and growing seasons.

Interpolation estimates values at unmeasured locations from sample points. Weather stations measure rainfall at a few hundred points, but you want a continuous rainfall surface.

  • Inverse distance weighting (IDW) assumes nearby points are more alike than distant ones (Tobler's first law of geography: "everything is related to everything else, but near things are more related than distant things"). Each estimate is a weighted average of nearby samples, with weights falling with distance.
  • Kriging is a geostatistical method that models how similarity changes with distance and also estimates uncertainty.
  • Spline fits a smooth surface through the points.

Interpolation works best with dense, well-spread samples and smoothly varying phenomena. It can mislead where samples are sparse, or where sharp changes occur, such as across a mountain ridge that blocks rain.

Step 9 of 12Try the calculator

NDVI calculator

Enter reflectance values (0 to 1) for the near-infrared and red bands of a pixel.

NDVI
0.724

Step 10 of 12Practice · Work it out

A pixel has near-infrared reflectance 0.40 and red reflectance 0.10. What is its NDVI? Round to two decimals.

Step 11 of 12Practice · Diagram

Reading NDVI values

Tap the surface that reflects more red than near-infrared light.

Tap the shape that answers the question, then press Check.

Reading NDVI valuesScale: Lake, Parking lot, Dry grassland, Our pixel: 0.60, Rainforest canopy.-1-0.75-0.5-0.2500.250.50.751-0.3Lake0.1Parking lot0.35Dry grassland0.6Our pixel: 0.600.85Rainforest canopy
Lake

-0.3

Parking lot

0.1

Dry grassland

0.35

Our pixel: 0.60

0.6

Rainforest canopy

0.85

Step 12 of 12Practice · Choose one

Which principle underlies inverse distance weighting interpolation?