As per Iterating over years for features in feature collection using Google Earth Engine?, I am currently working with the Hansen data (Global Forest Change) in Earth Engine. I have imported two feature collections representing districts in a specific country, as well as oil concessions for that country.
I figured out how to aggregate information for each district in its respective feature collection, as follows:
//Load and filter the Hansen data
var gfc2014 = ee.Image('UMD/hansen/global_forest_change_2015').select(['treecover2000','loss','gain','lossyear']);
//add country districts as a feature collection
var distr = ee.FeatureCollection('ft:1U7sXFHXtxQ--g7XMeXlvPhNXPBcDtPg8Yzr2pvsg', 'geometry');
//load oil palm concessions
var oilPalm = ee.FeatureCollection('ft:1Q-5XgXQpAeRhILPoPTx8gnGTzUpSJx-EtKu_BCw', 'geometry');
//get oil palm in country
var oilPalmCont = oilPalm.filterBounds(country);
//look at tree cover, find the area
var treeCover = gfc2014.select(['treecover2000']);
var areaCover = treeCover.multiply(ee.Image.pixelArea());
var lossIn2001 = gfc2014.select(['lossyear']).eq(1);
var areaLoss = lossIn2001.multiply(ee.Image.pixelArea());
var districtSums = areaCover.reduceRegions({
collection: distr,
reducer: ee.Reducer.sum(),
scale: 100,
});
//This function computes pixels lost for each district
var addLoss = function(feature) {
var loss = areaLoss.reduceRegion({
reducer: ee.Reducer.sum(),
geometry: feature.geometry(),
scale: 100
});
return feature.set({loss2001: loss.get('lossyear')});
};
// Map the area getting function over the FeatureCollection.
var areaLosses = districtSums.map(addLoss);
What I would like to do, is to reduce deforestation information over each concession, so that each concession has an associated loss area, and then to aggregate this information over district. In the end, the district feature collection should have a variables indicating number of concessions in the district, and area deforested in the concessions area.
I feel like this should be straight forward, but I can't figure out how to aggregate information over two features.
No comments:
Post a Comment