1

I want to calculate the area covered by forests in a region. Using Hansen image I have demarcated the forest regions in India. Now, how do I get the total area of forests?

 // FILTERING OUT FOREST COVER IN INDIA

var treeCanopyCover = hansen.clip(india).select('treecover2000');
var greater25 = treeCanopyCover.gte(25);
var treeCover_greater25 = treeCanopyCover.updateMask(greater25);

I know that I can use ee.Image.pixelArea(), and then subsequently use reduceRegion. But, I don't understand what scale I should give. In fact, I would like to know, what exactly are the roles of scale and maxPixels. Could someone enlighten me on this regard?

var areaImage = treeCover_greater25.multiply(ee.Image.pixelArea());

var stats = areaImage.reduceRegion({
  reducer: ee.Reducer.sum(),
  geometry: india,
  scale: 100,
  maxPixels: 1e13
});
0

This worked for me.

Instead of multiplying by ee.Image.pixelArea use mask function.

var areaImage = ee.Image.pixelArea().mask(treeCover_greater25);

var stats = areaImage.reduceRegion({
  reducer: ee.Reducer.sum(),
  geometry: india,
  scale: 30,
  maxPixels: 1e13
});

ee.Image.pixelArea() gives an image where value of each pixel corresponds to its area. When we mask this image with 'treeCover_greater25', any pixels in 'treeCover_greater25' that have the value 0 will be made transparent in ee.Image.pixelArea().

For more details go through this link : https://developers.google.com/earth-engine/tutorial_api_05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.