I have created a list of dates from which I would like to get Sentinel3 images, only to find that I have multiple images per day.
How can I reduce it to 1 image per day?
I intend to do use median
for the merging of the photos.
var region = ee.FeatureCollection([ee.Feature(Map.getBounds(true))])
//Dates of Interest
var start = ee.Date("2018-04-01");
var finish = ee.Date("2018-05-01");
//------------------- Data bases ---------------------//
var sen3 = ee.ImageCollection('COPERNICUS/S3/OLCI')
.filterDate(start, finish)
.filterBounds(region)
.select(['Oa17_radiance', 'Oa08_radiance'])
.map(function(image){
return image
.clip(region)
})
//reference dates
var sen2_for_dates = ee.ImageCollection('COPERNICUS/S2_SR')
.filterDate(start, finish)
.filterBounds(region)
.map(function(image){
return image
.clipToCollection(region)
.updateMask(image.select('QA60').not())
.addBands(image.normalizedDifference(['B8','B4']).rename('ndvi'))
})
.select('ndvi')
//------------------ Unique dates ----------------------//
var sen2_dates = sen2_for_dates.map(function(image){
return image.set('simpleDateMillis', ee.Date(ee.Date(image.date().format('YYYY-MM-dd'))))
});
var listMillisSimple = ee.List(sen2_dates.aggregate_array('simpleDateMillis'));
var uniqueDatesSimple = listMillisSimple.distinct();
var SEN2_day0 = uniqueDatesSimple
//THIS IS THE lIST OF DATES I WOULD LIKE TO GET IT's IMAGES
var SEN3_day0 = uniqueDatesSimple.map(function(date){
return ee.Date(date).advance(0, 'day');
});
var sen3_dates = sen3.map(function(image){
return image.set('simpleDateMillis', ee.Date(ee.Date(image.date().format('YYYY-MM-dd'))))
});
//The ImageCollection that should be containing the images from the specific dates
var allImagesInRangeS30 = sen3_dates.filter(ee.Filter.inList("simpleDateMillis", SEN3_day0))
I get these structures:
SEN3_day0
- List of 6 elements, dates (as needed).
sen3_dates
- ImageCollection of 409 images (to be filtered by the list of dates in SEN3_day0).
allImagesInRangeS30
- ImageCollection of 75 images (needs to be 6, as the list).