2

I have a code which coverts the MODIS Aqua dataset into monthly means. The code is here.

However, I'm want to do the same for a new data set, the NOAA/CDR/SST_WHOI/V2. However, rather than single daily values, this dataset has values 8 times a day. Is there a way of reducing this so it just collects one image per date, which I can then use the below code on?

var startyear = 2010; 
var endyear = 2011; 

var startmonth = 1;
var endmonth = 12;

var startdate = ee.Date.fromYMD(startyear, startmonth, 1);
var enddate = ee.Date.fromYMD(endyear , endmonth, 1);

var years = ee.List.sequence(startyear, endyear);

var months = ee.List.sequence(1, 12);
var monthlySST =  ee.ImageCollection.fromImages(
years.map(function (y) {
return months.map(function(m) {
  var w = UK_SST.filter(ee.Filter.calendarRange(y, y, 'year'))
                .filter(ee.Filter.calendarRange(m, m, 'month'))
                .mean();
  return w.set('year', y)
          .set('month', m)
          .set('system:time_start', ee.Date.fromYMD(y, m, 1));

});
}).flatten()
);
1
  • The script you shared in inaccessible. Can you please provide a different link and also add only the necessary code as as formatted code block to the question body. Mar 13, 2020 at 16:25

1 Answer 1

3

This question is very similar to: How to compute LST every 3rd day for 19 years (Earth Engine)

The code below modifies the answer slightly for your use case. Note that it makes median daily composites for the provided date range. You can change how the composite is generated (.mean(), .min(), .max(), etc) or use .first() to just select the first image per day. You should be able to use the resulting collection in your existing script.

var table = ee.Geometry(Map.getBounds(true));
var startDate = ee.Date('2018-01-01');
var endDate = ee.Date('2019-01-01');

var lst = ee.ImageCollection('NOAA/CDR/SST_WHOI/V2')
  .select('sea_surface_temperature')
  .filterBounds(table);

var days = endDate.difference(startDate, 'days');
var daysStep = 1;
var timeSeries = ee.ImageCollection(
  ee.List.sequence(0, days.subtract(1), daysStep)
    .map(function (offsetDays) {
      var start = startDate.advance(offsetDays, 'days');
      var end = start.advance(daysStep, 'days');
      var composite = lst
        .filterDate(start, end)
        .median(); // You need to decide how to combine the images
      return composite
        .set('system:time_start', start.millis())
        .set('empty', composite.bandNames().size().eq(0));
    })
  ).filterMetadata('empty', 'equals', 0);

print(timeSeries.size());
0

Your Answer

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

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