While exporting images the namings are not setting properly with the image date. How can I solve the problem?
I have attached the associated code:
// Import the MODIS NDVI dataset.
var modisNDVI = ee.ImageCollection("MODIS/006/MOD13Q1")
.select("NDVI"); // Select the NDVI band.
// Define a region of interest (ROI) or multiple ROIs (e.g., a feature collection).
var roi = ee.Geometry.Rectangle(-120.0, 35.0, -70.0, 45.0); // Example ROI.
// Define a time period.
var startDate = ee.Date('2021-01-01');
var endDate = ee.Date('2021-12-31');
// Function to export all MODIS NDVI images in the collection.
var exportAllNDVI = function(collection, roi, startDate, endDate) {
var imageList = collection
.filterDate(startDate, endDate)
.filterBounds(roi)
.toList(collection.size());
var imageCount = imageList.size().getInfo();
for (var i = 0; i < imageCount; i++) {
var image = ee.Image(imageList.get(i));
var date = ee.Date(image.get('system:time_start')).format("YYYY-MM-dd");
// Export the image to Google Drive with the date as the filename.
Export.image.toDrive({
image: image,
description: 'MODIS_NDVI_' + date,
folder: 'MODIS_NDVI_Exports',
region: roi,
scale: 250, // Adjust the scale as needed.
crs: 'EPSG:4326',
maxPixels: 1e13,
fileFormat: 'GeoTIFF'
});
}
};
// Run the exportAllNDVI function for the specified ROI and time period.
exportAllNDVI(modisNDVI, roi, startDate, endDate);