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
However I want to get statistics for all the districts (shown in figure below) separately.
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?