Repository navigation
Class Age
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.
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 Age |
consecutive years in the class | red (recent) to green (old) |
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.