1

I am using the MODIS Terra Continuous Vegetation Fields Global Yearly 250m dataset to derive PTC values for forests. For this, I need to filter pixels that have PTC values that are at least 10%. While I know how to do it on individual images, I am not sure as to how I can apply the same condition for a pixel throughout the image collection (10 years).[for all 10 years, the pixel must be at least 10%] I've tried the filter.Metadata() but I don't think the dataset has a metadata property for me to use. Any ideas as to how I can go about implementing the condition?

var PTC = ee.ImageCollection('MODIS/006/MOD44B')
  .filterDate('2001-01-01','2011-01-01')
  .filterBounds(MYR) //you could use a sample region
  .select('Percent_Tree_Cover')
  .map(function(image) { return image.clip(MYR)});

print(PTC);

var PTC_forests = PTC
  .filterMetadata('system:bands', 'not_less_than', 10); // not too sure which property I should use

Will mapping a function work instead? I believe this might only filter out pixels that fulfil the criteria within the image, rather than applying the same criteria on a pixel throughout the 10 years.

var PTC_forests = PTC.map(function (image){
    var forest = image.gte(10)
     return image.mask(forest)
});

1 Answer 1

0

By using gte(10), you'll make an image collection where each image with a pixel less than 10% of forest, becomes 0. If then the number of images equals the number of ones in that imageCollection, the pixel always has more than 10% of pixel throughout all images.

// the binary image collection 
var PTC_maskImgCol = PTC.map(function (image){
  return image.gte(10);
});

// make a single mask image from the collection
var maskImg = PTC_maskImgCol.sum().eq(PTC.size());

// Use the mask image to mask every single image in the original collection
var PTC_masked = PTC.map(function(image){
  return image.updateMask(maskImg);
});

link code

1
  • Thanks for the help! Just what I needed. Commented Oct 28, 2020 at 6:27

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.