I've merged three Landsat collections in Google Earth Engine, now I need to calculate median values at regular time intervals, let's say 32 days, because I will create a collection to join with MODIS. However, when I do that, I lose the "system:time.start" information from Landsat Merged collections. Does anyone knows how to calculate this regular medians based on DOY? I want to filter the Landsat_merge collection to 32 days regular interval!

This is the code so far: Code to access MODIS Landsat Joined collections


Here's a snippet to get you started, based on code in this blog post:

var temporalCollection = function(collection, start, count, interval, units) {
  // Create a sequence of numbers, one for each time interval.
  var sequence = ee.List.sequence(0, ee.Number(count).subtract(1));

  var originalStartDate = ee.Date(start);

  return ee.ImageCollection(sequence.map(function(i) {
    // Get the start date of the current sequence.
    var startDate = originalStartDate.advance(ee.Number(interval).multiply(i), units);

    // Get the end date of the current sequence.
    var endDate = originalStartDate.advance(
      ee.Number(interval).multiply(ee.Number(i).add(1)), units);

    return collection.filterDate(startDate, endDate).median()
        .set('system:time_start', startDate.millis())
        .set('system:time_end', endDate.millis());

var landsat8 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA');

var result = temporalCollection(landsat8, '2016-01-01', 12, 32, 'day');

var first = ee.Image(result.first());
Map.addLayer(first, {bands: ['B4', 'B3', 'B2'], min: 0, max: 0.3}, 'first');

Note that another variant of this is described in this answer.

| 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.