Skip to content

Number of Changes

João Siqueira edited this page Nov 10, 2026 · 2 revisions

Script: codes/analysis_4_number_of_changes.js. The calculation is in the function getNumberOfChanges.

Description: Counts how many times the class changed from one year to the next, as the number of runs (blocks of consecutive years with the same class) minus one. Pixels that never changed are masked.

What it shows: It measures landscape dynamism: high values indicate instability or frequent "flipping" between classes. Leaving a class and returning to it counts twice, so a pixel that goes from Forest to Pasture and back to Forest (pixel C in the example) has 2 changes but only 2 classes. Pixel A has 5 changes among 4 classes.

Number of changes on the four example pixels: A 5, B masked, C 2, D 2

Parameters

Set at the top of the script; change them before running.

variable default meaning
asset Collection 10.1 coverage asset the multi-band image read by the script
years 1985 … 2024 years included in the series
bandPrefix 'classification_' band names are bandPrefix + year

Map layers

Besides a land cover reference layer (hidden by default), the script adds:

layer value colors
Number of Changes number of changes light (few) to dark brown (many)

Pixels with no result are masked and appear transparent.

How to run

Copy the whole script into the Google Earth Engine Code Editor, adjust the parameters and click Run. See Home for the example pixels used in the figure.


← 3. Number of Distinct Classes · Home · 5. Stable Classes →

Clone this wiki locally