In the assessment of time since forest disturbance, we define disturbance as the drop of TCC from >=10% to 0%. Use following code or the link here.
var mekong = ee.FeatureCollection('users/biplov/gadm-mekong'), tcc = ee.ImageCollection('projects/servir-mekong/yearly_primitives_smoothed/tree_canopy'), tch = ee.ImageCollection('projects/servir-mekong/yearly_primitives_smoothed/tree_height'); var tccThreshold = 10; // in percentage var tchThreshold = 5; // in meter var years = ee.List.sequence(2000, 2018); var combineDatasets = function (year) { var _tcc = tcc.filterDate(ee.Date.fromYMD(year, 1, 1), ee.Date.fromYMD(year, 12, 31)).first(); _tcc = _tcc.rename(['tcc']); var _tch = tch.filterDate(ee.Date.fromYMD(year, 1, 1), ee.Date.fromYMD(year, 12, 31)).first(); _tch = _tch.rename(['tch']); return _tcc.addBands(_tch); }; var combinedData = ee.ImageCollection.fromImages(years.map(combineDatasets)); var calculateForestMap = function (image) { var _tcc = image.select('tcc').gte(tccThreshold); var _tch = image.select('tch').gte(tchThreshold); var zeroTCC = image.select('tcc').eq(0).rename(['zeroTCC']); return (_tcc.and(_tch).rename(['forest'])).addBands(zeroTCC).copyProperties(image, image.propertyNames()); }; var forestMapCollection = combinedData.map(calculateForestMap); // This is a function to pass to Iterate(). // As images are computed and added to the list. var accumulate = function(image, list) { var forest = image.select('forest'); var zeroTCC = image.select('zeroTCC'); // get(-1) the last image in the image collection var previous = ee.Image(ee.List(list).get(-1)).toUint8(); var added = previous.add(forest).set('system:time_start', image.get('system:time_start')); // set the value for a pixel to zero which has TCC dropped to zero added = added.where(zeroTCC.eq(1), 0); // Return the list return ee.List(list).add(added.toUint8()); }; var firstDate = forestMapCollection.first().get('system:time_start'); // The first image in the list is just 0; keep adding to get the age that meets criteria var firstImage = ee.Image(0).toUint8().set('system:time_start', firstDate).select([0], ['forest']); var collection = ee.List([firstImage]); // Create an ImageCollection of cumulative anomaly images by iterating. var cumulative = ee.List(forestMapCollection.iterate(accumulate, collection)); cumulative = cumulative.remove(cumulative.get(0)); var tsd = ee.Image(cumulative.get(-1)).rename(['tsd']); tsd = tsd.updateMask(tsd.gt(0)).clip(mekong); Map.addLayer(tsd, {min:1, max:31, palette:'red,orange,yellow,green,darkgreen'}, 'tsd');
Happy Earth Science 🙂
Leave a Reply