1

I would like to extract an image collection of some days.

For instance, if I want to extract an image collection between two dates, I can simply do:

START = '2010-08-01'
END = '2010-09-15'
cover = ee.ImageCollection('MODIS/006/MYD11A1').filter(ee.Filter.date(START, END))

What I would like to do is to filter based on a list of dates and do something like the following:

DATES = ['2010-08-01', '2010-08-12', '2010-09-01']
cover = ee.ImageCollection('MODIS/006/MYD11A1').filter(ee.Filter.date(DATES))

Is it possible?

1 Answer 1

1

I have added a 'Date' property to the ImageCollection, and then filter for specific dates:

var START = '2010-08-01'
var END = '2010-09-15'

var DATES = ['2010-08-01', '2010-08-12', '2010-09-01']

var addTime = function(x) {
  return x.set('Date', ee.Date(x.get('system:time_start')).format("YYYY-MM-dd"))}
  
var cover = ee.ImageCollection('MODIS/006/MYD11A1')
            .filter(ee.Filter.date(START, END))
            .map(addTime)
            .filter(ee.Filter.inList('Date',ee.List(DATES)))
print(cover)
2
  • You're welcome my friend
    – CrossLord
    Commented Mar 4, 2021 at 14:31
  • thank you, I adapted the code for python
    – emax
    Commented Mar 5, 2021 at 9:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.