I would like to create a list or array object containing a unique set of dates represented in an image collection for a given region of interest. I have a function that extracts and converts dates for each image to a number, and stores these as a list. However, there are often multiple images (tiles) for the same date, meaning the date list has many duplicates. How can I filter out replicate dates to get a unique date list?

See code here: https://code.earthengine.google.com/20de3ef240fd96d1b25f0b52b9dce5f3


//Dates of Interest
var start = ee.Date("2014-10-01");
var finish = ee.Date("2018-05-01");

///--------------------- Landsat Collection ---------------------------------------///
var landsat = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
.filterDate(start, finish)

// Year-Month-Day Extract function
function ymdList(imgcol){
    var iter_func = function(image, newlist){
        var date = ee.Number.parse(image.date().format("YYYYMMdd"));
        newlist = ee.List(newlist);
        return ee.List(newlist.add(date).sort())
    return imgcol.iterate(iter_func, ee.List([]));

2 Answers 2


You can find out how many images are available per date with the frequencyHistogram reducer. Script with example roi.

var ymd = ymdList(landsat)

I came across this thread looking for a python answer. The following function should work:

def ymdList(imgcol):
    def iter_func(image, newlist):
        date = ee.Number.parse(image.date().format("YYYYMMdd"));
        newlist = ee.List(newlist);
        return ee.List(newlist.add(date).sort())
    ymd = imgcol.iterate(iter_func, ee.List([]))
    return list(ee.List(ymd).reduce(ee.Reducer.frequencyHistogram()).getInfo().keys())

This actually returns a list of unique strings that are the dates. You can then convert them to datetime objects if necessary.

  • Exactly what I needed, thank you.
    – Matt
    Aug 10, 2021 at 7:55

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .