Skip to content

Class Age

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

Script: codes/analysis_1_age.js. The calculation is in the function getClassAge.

Description: Counts the consecutive years the pixel has belonged to the targetClass, going back from the last year of the series (2024). Any year in another class resets the count to zero, so only pixels that are in the target class in 2024 have an age.

What it shows: It separates "old" from "recent" areas. If the class is Pasture, a high value marks consolidated pasture and a low value a recent conversion. In the example, pixel A was pasture for 23 years in total, but its age is 11: only the years since 2014 count, because the soybean years broke the run. Pixels C and D are no longer pasture in 2024 and have no age.

Class age on the four example pixels: A 11 years, B, C and D masked

Parameters

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

variable default meaning
targetClass 15 (Pasture) class of interest, a MapBiomas legend code
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
Class 15 Age consecutive years in the class red (recent) to green (old)

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.


Home · 2. Class Frequency →

Clone this wiki locally