0

I am trying to calculate burned area for the districts of Punjab state. I have used following code

var admin2 = ee.FeatureCollection("FAO/GAUL_SIMPLIFIED_500m/2015/level2");
var state = admin2.filter(ee.Filter.eq('ADM1_CODE', 1505));
print(village)
var area = village.geometry();
// Show the state polygon with a blue outline
var outline = ee.Image().byte().paint({
  featureCollection: village,
  color: 1,
  width: 3
});
Map.addLayer(outline, {palette: ['red']}, 'AOI')
var dataset4 = ee.ImageCollection('MODIS/006/MCD64A1')
                  .filter(ee.Filter.date('2010-01-01', '2010-12-31'));
var burnedArea2 = dataset4.select('BurnDate').mosaic().clip(area);
var burnedAreaVis = {
  min: 1.0,
  max: 366.0,
  palette: ['fd4100', 'fb8200','ff0000','080fff','df2fff', 'f9c400', 'f2ff00', 'b6ff05',
    '7787f9', '8b211c', '088712', '21f5ff'],
};
Map.addLayer(burnedArea2, burnedAreaVis, 'MCD64A1 Burned Area');

///////area calculation MODIS MCD64A1/////
var burnedB = burnedArea2.select('BurnDate');
var pixelArea = ee.Image.pixelArea().updateMask(burnedB.mask());
print(pixelArea);

var stats = pixelArea.reduceRegion({
  reducer: ee.Reducer.sum(),
  geometry: area,
  scale: 500,
  maxPixels: 10e13,
  //tileScale: 4
});
print('pixels representing MCD64A1 Burned Area: ', stats.get('area'), 'square meters');

The results I am getting are kind of cumulative for all the polygons as follows enter image description here

However I want to get statistics for all the districts (shown in figure below) separately. enter image description here I can do it by individually processing them but is there any way where I can calculate the area statistics for each district polygon at a same time?

1 Answer 1

2

Use reduceRegions() instead of reduceRegion(). While reduceRegion() accepts a geometry and produces a dictionary of reducer outputs, reduceRegions() instead accepts a FeatureCollection and produces a FeatureCollection where each feature has the reducer outputs attached as properties.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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