Disturbance defined as a drop of TCC from >10% to 0%
use the code below or follow this link
// import tree canopy cover and tree canopy height
var tccCollection = ee.ImageCollection("projects/servir-mekong/UMD/tree_canopy");
var tchCollection = ee.ImageCollection("projects/servir-mekong/UMD/tree_height");
// combine the data
var combine = function(img){
var image = img.rename("tcc");
var t = ee.Date(img.get('system:time_start'));
var tch = ee.Image(tchCollection.filterDate(t,t.advance(100,"day")).first()).rename("tch");
return image.addBands(tch).set("system:time_start",t);
};
// combine the two datasets
var tccTch = tccCollection.map(combine);
// set the thresholds
var thtcc = 10;
var thtch = 5;
// get the tcc and tch and set the thresholds
var forestMap = function(img){
var t = ee.Date(img.get('system:time_start'));
var tcc = img.select("tcc").gte(thtcc);
var tch = img.select("tch").gte(thtch);
var zero = img.select("tcc").eq(0).rename("zero");
var forest = ee.Image(tcc.and(tch)).addBands(zero);
return forest.set("system:time_start",t);
}
// create the forest map
var forestCollection = tccTch.map(forestMap)
// create an empty map for the first year
var first = ee.List([ ee.Image(0).set('system:time_start', time0).select([0], ['tcc'])]);
// get the time of img 1
var time0 = forestCollection.first().get('system:time_start');
// function to iterate from 1987 to now
var accumulate = function(img, list) {
var image = img.select("tcc")
var zero = img.select("zero")
var previous = ee.Image(ee.List(list).get(-1));
var added = image.add(previous);
var result = added.where(zero.eq(1),0).set('system:time_start', image.get('system:time_start'));
return ee.List(list).add(result);
};
// we use iterate here as the calculate all in sequence
var tsdIterate = ee.ImageCollection(ee.List(forestCollection.iterate(accumulate, first)));
// get the 2018 image
var myImg = ee.Image(tsdIterate.toList(500).get(31))
// display the image
Map.addLayer(myImg,{min:0,max:31,palette:"red,orange,yellow,green,darkgreen"})