Skip to content

Class Frequency

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

Script: codes/analysis_2_frequency.js. The calculation is in the function getClassFrequency.

Description: Counts the total number of years the pixel was classified as the targetClass throughout the time series (1985–2024), consecutive or not.

What it shows: Unlike "Age," frequency does not require consecutive years, so it reveals the recurrence of a class. A pixel can have a low age and a high frequency when the class disappears and comes back, as in crop rotation or shifting cultivation. In the example, pixel A has a frequency of 23 (in three blocks) and an age of 11; pixel C, 20 years of pasture that ended in 2010, still has a frequency of 20.

Class frequency on the four example pixels: A 23, B masked, C 20, D 2

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 Frequency years in the class red (few) to green (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.


← 1. Class Age · Home · 3. Number of Distinct Classes →

Clone this wiki locally