Repository navigation
Class First Year
Script: codes/analysis_6_first_year.js. The calculation is in the function getClassFirstYear.
Description: Returns the earliest year in which the pixel was classified as the targetClass. It follows Class Last Year with the minimum instead of the maximum; the years outside the class are masked before the minimum, otherwise their value 0 would always win.
What it shows: When a class first appeared in each location, for example the year of the conversion to pasture. Together with the last year, it frames the period in which the class was present. In the example, pixel C entered pasture in 1991 and left it in 2010; pixel D entered only in 2017; pixel A has been pasture since 1993, with breaks in between.
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 First Year |
earliest year in the class | yellow (earlier) to dark red (recent) |
Pixels never in the class 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.
← 5. Stable Classes · Home · 7. Class Last Year →