I try to calculate the burn area from MCD64A1.061 MODIS Burned Area Monthly Global 500m (https://developers.google.com/earth-engine/datasets/catalog/MODIS_061_MCD64A1) on GEE, based on the specific confidence level. The code worked perfectly until I attempted to filter the burn area based on the uncertainty, or the confidence level.
The error said: Number (Error) Dictionary.getNumber: Dictionary does not contain key: FireOccurance.
Here is the link to the code: https://code.earthengine.google.com/ee7eac7c6d03fb55cfe6000dd6336115?accept_repo=users%2Fgorelick%2FEE101-B
var dataset = ee.ImageCollection('MODIS/061/MCD64A1')
.filterDate('2000-12-31', '2002-12-31')
.filterBounds(ROI)
.filter(ee.Filter.lt('Uncertainty', 30))
//create a function to calculate the area based on the pixel with "BurnDate", and clip with the ROI.
//ee.Image.pixelArea() method
//which generates an image in which the value of each pixel is the pixel's area (m2).
var clip = function(image){
return ee.Image.pixelArea()
.updateMask(image.select('BurnDate'))
.clip(ROI);
};
var clipDataset = dataset.map(clip)
//reduce the image until it pass through the first non-nill pixel value.
//rename the band
var burnedArea = clipDataset.reduce(ee.Reducer.firstNonNull())
.rename('FireOccurance');
var burnedAreaVis = {
palette: ['ffaaa6', 'ff8178', 'ff5445', 'ff0000'],
};
Map.addLayer(burnedArea, burnedAreaVis, 'Total Burned Area');
var BAcalculation = burnedArea.reduceRegion({
reducer: ee.Reducer.sum(),
geometry: ROI,
scale: 500,
maxPixels: 1e9
});
// calculate the burn area and conver it from m2 to km2
var totalBurnedArea = BAcalculation.getNumber('FireOccurance').divide(1000000);
print(totalBurnedArea, 'Total burned area in km2')
Is it because I filtered the images according to the certain 'Uncertainty' band and also try to calculate the area based on the 'BurnData' band? How should I solve it?