Repository navigation
Class Last Year
Script: codes/analysis_7_last_year.js. The calculation is in the function getClassLastYear.
Description: Returns the most recent year in which the pixel was classified as the targetClass. Its counterpart is Class First Year, the earliest year. Time Since Last Occurrence expresses it as years elapsed until 2024.
What it shows: It maps the temporal footprint of a class: where a class is no longer present, it tells when it was last seen. In the example, pixel C left pasture in 2010 and pixel D in 2018; pixel A is still pasture, so its value is the last year of the series, 2024.
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 Last Year |
most recent year in the class | yellow (earlier) to dark red (recent) |
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.
← 6. Class First Year · Home · 8. Time Since Last Occurrence →