[GIS] Filter image collection with a date list in Google Earth Engine

datefiltergoogle-earth-engine

I know how to filter with a date range in Google Earth Engine, but I would like to filter a list of concrete dates which aren't consecutive, single days, for example, ['2005-08-05','2009-09-01','2017-02-08'].

var collection = ee.ImageCollection("MODIS/MYD11A1").select('LST_Day_1km');

var reference = collection.filterDate('2016-01-01', '2016-12-31')

Best Answer

Make a list of millisecond dates, and then use filter inList:

var collection = ee.ImageCollection("MODIS/MYD11A1").select('LST_Day_1km');

var reference = collection.filterDate('2016-01-01', '2016-12-31')

var datelist = ee.List(['2005-08-05','2009-09-01','2017-02-08'])
.map(function(date){return ee.Date(date).millis()})

var newcol = collection.filter(ee.Filter.inList("system:time_start", datelist))

print(newcol)