# Calculating Annual Burned area using MODIS/006/MCD64A1

I am struggling to calculate annual burned area using MODIS/006/MCD64A1 and plotting it to graph for the historical burned area in ROI. However, I'm not sure whether my result is correctly calculated, as well as my code for extracting annual burned area with my region of interest. Here is my code :

``````var startDate = ee.Date('2010-01-01'); // set start time for analysis
var endDate = ee.Date('2020-12-31'); // set end time for analysis

// calculate the number of months to process
var nYears = ee.Number(endDate.difference(startDate,'year')).round();
print(nYears)

var projection = 'EPSG:32620'

var sst =  ee.ImageCollection("MODIS/006/MCD64A1")
.select('BurnDate')
.filterDate(startDate, endDate)

var byYear = ee.ImageCollection(
// map over each year
ee.List.sequence(0,nYears).map(function (n) {
// calculate the offset from startDate
// filter and reduce
return sst.filterDate(ini,end)
.select(0).max()
.set('system:time_start', ini);
}));
// ** Calculate Total Burned A1rea
var burned_areas = ee.Image.pixelArea().divide(10000)
var stats_burned_area = burned_areas.reduceRegion({
reducer : ee.Reducer.sum(),
geometry :roi,
scale : 500,
crs :projection,
maxPixels:1e12,
tileScale:4})

print (stats_burned_area)
print(byYear,'Test');

// plot full time series
print(
ui.Chart.image.series({
imageCollection: byYear,
region: roi,
reducer: ee.Reducer.sum(),
scale: 500
}).setOptions({title: 'Burned Area over time'})
);

// plot a line for each year in series
print(
ui.Chart.image.doySeriesByYear({
imageCollection: byYear,
bandName:'BurnDate',
region: roi,
regionReducer: ee.Reducer.sum(),
scale: 500,
}).setOptions({title: 'SST for each year'})
);
``````

Does somebody know how to calculate annual burned area using this dataset?

• As per the help center please do not include chit chat like thanks and other statements of appreciation within your posts.
– PolyGeo
Aug 19 at 19:17

You were really close to obtaining the total burned area by year. You just need to move the part for calculating the burned area inside the `map`, so this process is done for every year. Afterwards, to return the total burned area by year, you should add that value as a property to a `ee.Feature` without a geometry. Finally, you can export the byYear object (which is a `ee.FeatureCollection`) as a CSV file with `Export.table.toDrive`.

``````var startDate = ee.Date('2010-01-01'); // set start time for analysis
var endDate = ee.Date('2021-01-01'); // set end time for analysis

// calculate the number of years to process, subtract 1 to use 2010 - 2020
var nYears = ee.Number(endDate.difference(startDate,'year')).round().subtract(1);
print(nYears)

var projection = 'EPSG:32620'

var sst =  ee.ImageCollection("MODIS/006/MCD64A1")
.select('BurnDate')
.filterDate(startDate, endDate)

print('sst',sst);
var byYear = ee.FeatureCollection(
// map over each year
ee.List.sequence(0,nYears).map(function (n) {
// calculate the offset from startDate
// filter collection to stay with images from ini year
var resul = sst.filterDate(ini,end);
// Reduce the collectino using the max reducer
resul = resul.max()
.set('system:time_start', ini);
// Get image where BurnDate was not 0 and use it as mask
// to apply it the Image containing the area by pixel
resul = ee.Image.pixelArea()
.divide(10000)
// Reduce the image by summing all the pixels that are not
resul = resul.reduceRegion({
reducer: ee.Reducer.sum(),
geometry:roi,
scale: 500,
crs: projection,
maxPixels: 1e12,
tileScale: 4
});
// Export the area inside a Feature without geometry
return ee.Feature(null, {'area_ha': resul});
}));

print('Area_ha Burned by year', byYear);
``````
• How to convert it to Dictionary, so i can add area by year in console as well as making a graph from it? Aug 20 at 6:08
• For doing that you should add the property year to the Feature returned in the mapped function as `'year': ini.get('year')`. Then you can make the chart with `ui.Chart.feature.byFeature`. Finally, for printing the dictionary in the console you can do extract the year and area properties as lists and join them in a dictionary as: `var area = byYear.aggregate_array('area_ha'); var year = byYear.aggregate_array('year'); var resulDict = ee.Dictionary.fromLists(year.map(function(y){ return ee.String(y); }), area); print('resulDict', resulDict);` Aug 20 at 14:52