Skip to content

Class First Year

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

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.

Class first year on the four example pixels: A 1993, B masked, C 1991, D 2017

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 First Year earliest year in the class yellow (earlier) to dark red (recent)

Pixels never in the class 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.


← 5. Stable Classes · Home · 7. Class Last Year →

Clone this wiki locally