1

I'm trying to figure out a function to filter image by quarter (January - March, Arpil - July, etc) of Landsat Image Collection to calculate NDVI for each three-month period between 2013 and 2018. My purpose is to adjust the code this link https://code.earthengine.google.com/f590c95bd17454789cde0eb8d1be4850 to compute NDVI in quarter instead of five-year period.

I am planning to add this code below, however i don't know exactly it could be possible or not.

var start = ee.Date('01-01-2013');
var end = ee.Date('31-03-2013');
var date_range = ee.DateRange(start,end);
var fnc = function(d1) {
  var S1 = ee.ImageCollection("LANDSAT/LC08/C01/T1_SR")
    .filterDate(date_range)
    .filterBounds(table)
  return(S1.first())
}
var quarter1 = ee.ImageCollection(dates.map(fnc));
print(mt)


1

There are multiple ways to make these composite image. Note that you will have to choose a manner to reduce multiple images within the three-month date range to one image. .first() is generally a bad choice. I would recommend .median() for simple composites:

// get start and end date and define the number of quarterly composites
var start = ee.Date('2013-01-01');
var end = ee.Date('2019-01-01');
var numbQuarters = end.difference(start, 'month').divide(3).ceil();

// make a composite image for every quarter
var quarterlyImages = ee.ImageCollection.fromImages(
            ee.List.sequence(1, numbQuarters).map(function(quarter){
              var startTemp = start.advance(
                              ee.Number(quarter).subtract(1).multiply(3), 'month');
              var endTemp = start.advance(ee.Number(quarter).multiply(3), 'month');
              var image = ee.ImageCollection("LANDSAT/LC08/C01/T1_SR")
                                .filterDate(startTemp, endTemp)
                                .filterBounds(geometry)
                                // define a way to composite an image
                                .median(); // .mean(); .mosaic(); .max(); etc

              return image.set('system:time_start', startTemp.millis(),
                               'system:time_end', endTemp.millis());
            }));

Link code

| improve this answer | |
0

Thank you for your kindness, Anyway I'm trying to use .clip(table) function to cut the table polygon however it's not working (quarterlyImages.clip is not a function). Could you please tell me how to adjust the code ?

"print('image collection', quarterlyImages)
print('startDates', quarterlyImages.aggregate_array('system:time_start'))
print('sendDates', quarterlyImages.aggregate_array('system:time_end'))
Map.addLayer(quarterlyImages.clip(table),{ min:0, max: 3500, bands: 'B6, B5, B4'});
Map.centerObject(table, 7);

https://code.earthengine.google.com/9cf431a559131a62d54c7d4977559e9e

Thank you!

| improve this answer | |

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.