I am using MCD64A1.006 MODIS Burned Area Monthly Global 500m product in GEE and trying to count the number of pixels with a value inside of each grid cell in a vector grid I created.
// load MCD64A1 Version 6 Burned Area
var dataset = ee.ImageCollection(imageCollection)
.filter(ee.Filter.date('2018-01-01', '2018-12-31'))
.filterBounds(border);
var burnedArea = dataset.select('BurnDate')
// add grid
Map.addLayer(grid, {color: 'white'}, '1degree grid', true);
// count pixels
var pixC = burnedArea.reduceRegion({
reducer: ee.Reducer.count(),
geometry: grid,
scale: 500,
maxPixels: 1e9
});
print(pixC)
a link to the grid asset: https://code.earthengine.google.com/?asset=users/stavo/Vectorgrid_1degree
I assumed that if I provide a multipolygon as a geometry for the reducer I will get a separate result for each grid cell. However, I receive a count of all existing pixels in all cells.
Is there a way to get a count for each cell?