I'm new to GEE. I have used this code to view the mosaic data. How should I export each mosaic data with unique file name (date).
var aoi = ee.FeatureCollection('users/sujithapeterraj/HAssan')
var s2 = ee.ImageCollection('COPERNICUS/S2_SR')
.filterBounds(aoi)
.filterDate('2019-01-01', '2019-01-30'); // // %Y-%m-%d
print(s2.first(), 'first image s2');
// Function to mosaic by date, orbit, etc
function mosaicBy(imcol){
// imcol: An image collection
// returns: An image collection
// return the collection as a list of images (not an image collection)
var imlist = imcol.toList(imcol.size());
// Get all the dates as list
var all_dates = imlist.map(function(im){
return ee.Image(im).date().format("YYYY-MM-dd");
});
// get all orbits as list
var all_orbits = imlist.map(function(im){
return ee.Image(im).get('SENSING_ORBIT_NUMBER');
});
// get all spacecraft names as list
var all_spNames = imlist.map(function(im){
return ee.Image(im).get('SPACECRAFT_NAME');
});
// this puts dates, orbits and names into a nested list
var concat_all = all_dates.zip(all_orbits).zip(all_spNames);
// here we unnest the list with flatten, and then concatenate the list elements with " "
concat_all = concat_all.map(function(el){
return ee.List(el).flatten().join(" ");
});
// here, just get distinct combintations of date, orbit and name
var concat_unique = concat_all.distinct();
// mosaic
var mosaic_imlist = concat_unique.map(function(d){
// split into components
var d1 = ee.String(d).split(" ");
var date1 = ee.Date(d1.get(0));
var orbit = ee.Number.parse(d1.get(1)).toInt();
var spName = ee.String(d1.get(2));
var im = imcol
.filterDate(date1, date1.advance(1, "day")) // filter with start date, and then end date, ie date + 1 day
.filterMetadata('SPACECRAFT_NAME', 'equals', spName)
.filterMetadata('SENSING_ORBIT_NUMBER','equals', orbit)
.mosaic();
return im.set(
"system:time_start", date1.millis(),
"system:date", date1.format("YYYY-MM-dd"),
"system:id", d1);
});
return ee.ImageCollection(mosaic_imlist);
}
var s2day = mosaicBy(s2);
print(s2day);
// Make list of image to display each one
var listOfImages = s2day.toList(s2day.size());
Map.centerObject(aoi, 6);
Map.addLayer(s2day.first(), {bands: 'B4,B3,B2', min: 300, max: 3000});
Map.addLayer(ee.Image(listOfImages.get(1)), {bands: 'B4,B3,B2', min: 300, max: 3000}); // second image
Map.addLayer(ee.Image(listOfImages.get(2)), {bands: 'B4,B3,B2', min: 300, max: 3000}); // third image
Map.addLayer(ee.Image(listOfImages.get(3)), {bands: 'B4,B3,B2', min: 300, max: 3000}); // 4th image