I am looking for a way to know how many images I have in a specific time frame. (I will later want to have all of their indexes and dates written in a list, so I can address them later on).
I have filtered the ImageCollection to 1 month, which should give me approx. 6 images for Sentinel-2 (revisit time should be 5 days), but I get a ridiculously high number. Also, I am not able to extract the dates as I need (first and last date of the collection).
var ndvi_s2 = ee.ImageCollection('COPERNICUS/S2_SR')
.filterDate('2019-01-01', '2019-02-01')
.map(function (image) {
return image
.clipToCollection(region)
.updateMask(image.select('QA60').not())
.normalizedDifference(['B8', 'B4'])
})
// Limit the collection to the 10 most recent images.
var recent = ndvi_s2.sort('system:time_start', false).limit(5);
print('Recent images: ', recent);
// Get the number of images.
var count = ndvi_s2.size();
print('Count ALL: ', count);
var count = recent.size();
print('Count recent: ', count);
// Get the date range of images in the collection.
var range = recent.reduceColumns(ee.Reducer.minMax(), ["system:time_start"])
print('Date range: ', ee.Date(range.get('min')), ee.Date(range.get('max')))
// Sort by a cloud cover property, get the least cloudy image.
var image = ee.Image(recent.sort('CLOUD_COVER').first());
print('Least cloudy image: ', image, ' Cloud Cover: ', image.get('CLOUD_COVER'));
These are the results:
Any ideas? Why do the "ALL" numbers is so big? And why can't I get the dates?
By the way - is there a way of seeing the NDVI values for the images I have printed out? I mean - see it in the console.