0

I am trying to get image collection of MODIS daily LST for monsoon season for a region that often has cloudy days. Filtering MODIS collection with filterBounds seems unable to remove scenes that have no pixel in study area.

First, I checked them with printing number of scenes in each collection

// Boundary
var DMDP = ee.Geometry.Rectangle(90.24, 23.59, 90.62, 24.00);
Map.centerObject(DMDP);

// Filtered by boundary
var terra_filtered = ee.ImageCollection('MODIS/061/MOD11A1')
  .filter(ee.Filter.date('2021-06-01', '2021-09-30'))
  .select('LST_Day_1km')
  .filterBounds(DMDP);
print(terra_filtered);

// Not filtered by boundary
var terra = ee.ImageCollection('MODIS/061/MOD11A1')
  .filter(ee.Filter.date('2021-06-01', '2021-09-30'))
  .select('LST_Day_1km');
print(terra); // Both image collection yeilds same number of images

Then, I checked if there are images which does not contain any pixel, e.g., I checked the first image of the collection and found that the image is empty. To be sure, I counted the pixels and it was confirmed - it does not have any pixel.

// First image
var monsoon = terra.first();
var visparams = {min: 13000.0, max: 16500.0, palette: ['green', 'yellow', 'red']};
Map.addLayer(monsoon.clip(DMDP), visparams, 'monsoon'); // No pixel visible in study area

// Print number of pixels to check if visual inspection is right
var pixels = monsoon.reduceRegion({
  reducer: ee.Reducer.count(),
  geometry: DMDP,
  scale: 500,
});
print('Pixels:', pixels);

What could be the possible ways to discard the zero pixel scenes from the image collection, other then the filterBounds? Also, why does filterBounds do not work in this case?

Link to GEE code

1 Answer 1

0

Solved it! I wrote a function to clip the scenes with study area and counted pixels of the scene. I had some hiccup there - I had to access value of dictionary, which was in list; then access the counted value from the list using its index.

Then, all I had to do was filter the image collection with pixel_count>0. Do let me know if you have better way to do this

// Function to clip scenes
var clipped = function (img) {
    img = img.clip(DMDP);
    var pixels = img.reduceRegion({
          reducer: ee.Reducer.count(),
          scale: 1000
       });
    pixels = pixels.values(['LST_Day_1km']).get(0)
    return img
      .copyProperties(img,['system:time_start','system:time_end'])
      .set('pixel_count', pixels)
      ;
};
// Remove null scenes by filtering the images with zero number of pixels
var clip_monsoon = terra.map(clipped)
  .filter(ee.Filter.gt('pixel_count', 0));
print (clip_monsoon)

Link to final GEE code

Your Answer

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

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