Repository navigation
Class Frequency
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.
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
|
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.
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.