Calculate time since forest disturbance

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 =;

// 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 ="tcc").gte(thtcc);
    var tch ="tch").gte(thtch);
    var zero ="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 =

// 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 ="tcc")
  var zero ="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


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s