0

I have an Image of LULC raster values where each band represents the classification for the years 2000-2023. I would like to count the last number of consecutive forest classifications (LULC code 3) for each pixel.

For example, with 10 fictitious years, the bands for a pixel and the resulting value looks like:

  • 1,3,4,3,3,3,3 -> 4
  • 3,3,7,7,7,3,7 -> 1

I have looked into counting runs for the longest consecutive block of 3's, but cannot figure out how to do it for the last consecutive block.

Here is the initial code so far:

var lulc = ee.Image('projects/mapbiomas-public/assets/brazil/lulc/collection9/mapbiomas_collection90_integration_v1');

var years = ee.List.sequence(2000, 2023);
var bandNames = years.map(function(y) { return ee.String('classification_').cat(ee.Number(y).toInt()); });
var selected = lulc.select(bandNames);

// TODO: Count number of last consecutive LULC=3's.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.