As my question in Remove alternate features from ImageCollection was put on hold, I am clarifying the question here.

I am using google earth engine for some analysis. I can import MODIS vegetation indices data at 16-day intervals and Land Surface Temperature/Emissivity at 8 day interval.

These data are imported as earthengine ImageCollection.

Is there a way on how to filter out only those images in LST imagecollection which correspond to dates in vegetation indices data. In another way, How can I filter the LST imagecollection to get 16 day ImageCollection?


  • It is always best to update and edit your original question and vote to reopen. – Aaron Jun 24 '18 at 2:25

Well, this would be just one workaround:

var lst = ee.ImageCollection("MODIS/MYD11A2").sort("system:time_start");

// Use an iterating function passing as first argument a list
// containing: [empty list, switch value]

var filtered = lst.iterate(function(img, it_var){

  // cast and get iteration values
  var newcol = ee.List(ee.List(it_var).get(0))
  var swich = ee.Number(ee.List(it_var).get(1))

  // change swich
  swich = ee.Number(ee.Algorithms.If(swich, 0, 1))

  // get the img only if swich is 0
  var filter = ee.List(ee.Algorithms.If(swich, newcol, newcol.add(img)))

  // cast and return
  return ee.List([filter, swich])

}, ee.List([ee.List([]), 1]))

// cast result
var result = ee.List(filtered)

// get acual ImageCollection from result
var filtered_col = ee.ImageCollection(result.get(0))

// print results

and remember when you ask to include actual code in the question, and not just a link (as an EE user I understand the reason, but this is Stack Exchange and there are rules and conventions)

  • Thanks, I am new to EE so thought that EE users like the code in EE code-editor. – Gaurav Vashisth Nov 21 '17 at 11:03
  • Yes, it's fine, you should include both. Did the code work as you expected? – Rodrigo E. Principe Nov 21 '17 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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