I am using the code below to export one image with 12 bands for year the year 2015, if want to generate the images for each year from 2000 on, is there any way to automate this to generate one image per year, without having to change the dates of the code each time?
// Export Burned Area Australia
//
var col = ee.ImageCollection("MODIS/006/MCD64A1")
.filterDate('2015-01-01', '2016-01-01')
.select('BurnDate');
// Define the regional bounds
var region = ee.Geometry.Polygon(
[[[139.81147500927887, -22.584034738321385],
[139.81147500927887, -39.52984428265981],
[155.19233438427887, -39.52984428265981],
[155.19233438427887, -22.584034738321385]]], null, false);
Map.addLayer(region)
// Clip and add a date band
var clipToRegion = function(img) {
var dateString = ee.Date(img.get('system:time_start')).format('yyyy-MM-dd');
var clipped = img.clip(region)
return clipped.rename(dateString)
};
var burned_area = col.map(clipToRegion);
var scal = burned_area.first().projection().nominalScale();
var check = ee.Image(burned_area.first());
Map.addLayer(check, {palette: ['000000', '00FFFF'], max: 366}, 'check');
print('Scale', scal )
// Stack One layer by year
//
var stackCollection = function(collection) {
// Create an initial image.
var first = ee.Image(collection.first()).select([]);
// Write a function that appends a band to an image.
var appendBands = function(image, previous) {
var dateString = ee.Date(image.get('system:time_start')).format('yyyy-MM-dd');
return ee.Image(previous).addBands(image);
};
return ee.Image(collection.iterate(appendBands, first));
};
var evi_img = stackCollection(burned_area);
print("EVI image stack",evi_img);
Export.image.toDrive({
image: evi_img,
description: 'BurnedAreaAustralia',
scale: 463.3127165275,
region: region,
fileFormat: 'GeoTIFF',
formatOptions: {
cloudOptimized: true
}
});