0

I would like to calculate the loss area in a certain elevation class in GEE. When I run the code 1 below, it gives the same amount as the total loss area in my study region, code 2. I switched arealoss and class3 in code 1 as well, and didn't work. How can I calculate the loss area in a certain elevation class?

code 1:

var arealoss= loss.multiply(ee.Image.pixelArea()).divide(10000);
var class3 = elevation.eq(3).selfMask();
var stats1 = arealoss.reduceRegion({ reducer: 
ee.Reducer.sum(),
geometry: class3.geometry(),
scale: 30,
maxPixels: 1e9,
bestEffort: true });

code 2:

var stats2 = arealoss.reduceRegion({
            reducer: ee.Reducer.sum(),
            geometry: peru.geometry(),
            scale: 30, 
            maxPixels: 1e9,
            bestEffort: true });

Besides, I want to repeat this calculation for 7 different elevation classes. is it possible to write a function for this calculation in GEE?

1
  • Hey there! Could you provide more context for the code (i.e. define loss, elevation etc.) so we can test it? – Madeleine Jan 6 at 23:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.