0

I am trying to run a time series analysis for a Lake in Africa. Since my area of interest is at the equator it is affected by gaps every few days where the sensor has not covered the full area (see Figure below). An example is given in the code below for the 2nd October 2015, where only the edge of the lake is included in the MODIS path. If i include this image in my time series then the average across the AOI for that day is incorrect. So, I am looking for a way to filter the imageCollection to exclude dates when the full Area of Interest was not covered.

//Import image 
var image = ee.Image('MOD09GA/MOD09GA_005_2015_10_02');
//Area of interest 
var AOI = /* color: #d63000 */ee.Geometry.Polygon(
    [[[35.48583984375, 2.1967272417616712],
      [36.97998046875, 2.1967272417616712],
      [37.1337890625, 4.631179340411012],
      [35.3759765625, 4.653079918274051]]]);
// True Colour Composite 
 var visParams = {bands: ['sur_refl_b01', 'sur_refl_b04', 'sur_refl_b03']};
//Add to map 
Map.addLayer(image, visParams, '2ndOct2015');

Image of MODIS daily path with gaps at equator: https://eoimages.gsfc.nasa.gov/images/imagerecords/0/687/world_2000_110_rgb143_lrg.jpg

Thank you!

2 Answers2

0

You could do something like this:

var mod09 = ee.ImageCollection("MODIS/006/MOD09GA");
var image = ee.Image('MOD09GA/MOD09GA_005_2015_10_02');
var visParams = {bands: ['sur_refl_b01', 'sur_refl_b04', 'sur_refl_b03']};
Map.addLayer(image, visParams, '2ndOct2015');

//Area of interest 
var AOI = /* color: #d63000 */ee.Geometry.Polygon(
    [[[35.48583984375, 2.1967272417616712],
      [36.97998046875, 2.1967272417616712],
      [37.1337890625, 4.631179340411012],
      [35.3759765625, 4.653079918274051]]]);
Map.centerObject(AOI);
Map.addLayer(AOI);

var count = image.select('sur_refl_b01').unmask().reduceRegion({
  reducer: 'count', 
  geometry: AOI, 
  scale: image.select('sur_refl_b01').projection().nominalScale(),
});
print(count);

var counter = function(image) {
  return image.set(image.select('sur_refl_b01').unmask().reduceRegion({
    reducer: ee.Reducer.count(), 
    geometry: AOI, 
    scale: image.select('sur_refl_b01').projection().nominalScale(),
  }));
};

var filteredCollection = mod09
  .filterDate('2016-01-01', '2016-12-31')
  .map(counter)
  // You probably want to add some delta here.
  .filter(ee.Filter.gte('sur_refl_b01', count.get('sur_refl_b01')));
print(filteredCollection);
  • Hi Nicholas! Thank you for your script!! One quick thing, what do you mean by delta? I also found an earlier response you made for a similar function which seems to work. Can you see any issues with it? I have added it as an answer. – Harriet Wilson Aug 25 '17 at 13:03
  • You wanted to filter areas for which the area is not completely covered. Your answer is not an answer to this question. I believe this will only filter images that are completely empty, leaving images which may be partially empty. The delta I referred to addresses this. It represents the allowable number of null pixels, which might be greater than zero. – Nicholas Clinton Aug 25 '17 at 19:10
0

This seems to work, which i adapted from a thread on GEE help forum.

////// MODIS COLLECTION ////////
var ci = ee.ImageCollection('MOD09GA').filterDate('2015-10-01', '2016 08-05');

// Function to exclude MODIS swath gaps  
function filterEmpty(imageCollection, polygon) {
var scale = 500
return imageCollection.map(function(i) {
  return i.set('first_value', i.select(0)
      .reduceRegion({reducer: ee.Reducer.firstNonNull(), geometry: polygon, scale: scale})
     .values().get(0))
}).filter(ee.Filter.eq('first_value', 1))
}
var c = filterEmpty(ci, Turkana);
print(c);