0

I want to calculate area of pixels within a country ('Uruguay' in the case below) that overlap with plantations in that country. However, after a bit of pre-processing a dataset (plantation_before_2000 in this case), I am getting User memory limit exceeded error.

Can someone tell me a way around it?

// Load the country feature for Bolivia
var geometry_clip = ee.FeatureCollection("FAO/GAUL/2015/level0")
  .filter(ee.Filter.eq('ADM0_NAME', 'Uruguay'));

// Read Hansen data
var hansen_boundary = ee.Image('UMD/hansen/global_forest_change_2021_v1_9');
var hansen_loss_year = hansen_boundary.select(['lossyear']);

var hansen_loss_year = hansen_loss_year.updateMask(hansen_baseline.gt(0))
Map.addLayer(hansen_loss_year, loss_vis, 'Forest Loss Year (for >25% baseline)', false)

var hansen_loss = hansen_boundary.select(['loss']).updateMask(hansen_baseline.gt(0));
Map.addLayer(hansen_loss, {'palette': 'black'}, 'Forest Loss (for >25% baseline)', false)

// Seperating plantation before 2000
var plantation_before_2000 = plantation.updateMask(plantation.lt(2001))

// Forest loss in last 20years attributed to plantations before year 2000
var forestloss_att_to_plantation_before_2000 = hansen_loss.updateMask(plantation_before_2000.gt(0));
Map.addLayer(forestloss_att_to_plantation_before_2000, {'palette': 'red'}, 'Forestloss attribution (plantation pre-2000)') 

// Hansen forest loss area check for regions with plantation pre-2000's
var forestloss_att_to_plantation_before_2000_area = forestloss_att_to_plantation_before_2000.multiply(ee.Image.pixelArea()).multiply(0.0001);

var Loss_Area_ByYear = forestloss_att_to_plantation_before_2000_area.addBands(hansen_loss_year).reduceRegion({
  reducer: ee.Reducer.sum().group({
    groupField: 1
    }),
  geometry: geometry_clip,
  scale: 30,
  maxPixels: 1e9
});
print('Deforestation attribution to Plantation', Loss_Area_ByYear);

Although the above code doesn't work, the one below works fine. Why is that?

// Hansen forest loss area check 
var hansen_loss_area = hansen_loss.multiply(ee.Image.pixelArea()).multiply(0.0001);

var Loss_Area_ByYear = hansen_loss_area.addBands(hansen_loss_year).reduceRegion({
  reducer: ee.Reducer.sum().group({
    groupField: 1
    }),
  geometry: geometry_clip,
  scale: 30,
  maxPixels: 1e9
});
print('Total forest loss', Loss_Area_ByYear);
Ep1c1aN
  • 683
  • 9
  • 25

0 Answers0