I would like to calculate the loss area in a certain elevation class in GEE. When I run 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. Besides, elevation(1), (2), .. all classes give the same result. How can I calculate the loss area for each elevation class?
code 1:
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?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…