Search code examples
javascriptgoogle-earth-engine

select one image from a specific month of an imageCollection in google earth engine


I would like to keep in Landsat 8 32-Day NDVI Composite imageCollection one layer in decembre between 2014 and 2017. Is there any way to do a variable filter ? Or a filter on month ?


Solution

  • For filtering a specific month, you can use ee.Filter.calendarRange within the filter method of the ImageCollection:

    var collection = ee.ImageCollection('LANDSAT/LC8_L1T_32DAY_NDVI')
    .filter(ee.Filter.calendarRange(12,12,'month'));
    

    The result gives you an ImageCollection containing the following images:

    0: Image LANDSAT/LC8_L1T_32DAY_NDVI/20131219 (1 band)
    1: Image LANDSAT/LC8_L1T_32DAY_NDVI/20141219 (1 band)
    2: Image LANDSAT/LC8_L1T_32DAY_NDVI/20151219 (1 band)
    3: Image LANDSAT/LC8_L1T_32DAY_NDVI/20161218 (1 band)
    

    As to selecting a specific image, you can either do the same filtering on the year or convert the ImageCollection to a list and select the image you want.

    HTH