1

I'm trying to filter Landsat images based on the percent of cloud cover for my ROI. I have tried to adapt code in link one and link two but cannot get what I want. My ROI has been imported as a feaureCollection and covers 8 Landsat tiles.

This is my code

//select images from image collection
var l8 = ee.ImageCollection('LANDSAT/LC08/C01/T1')
//LT05, LE07, LC08
.filterDate('1980-01-01', '2018-12-31')
.filter(ee.Filter.or(
ee.Filter.and(ee.Filter.eq('WRS_PATH', 208),         
              ee.Filter.eq('WRS_ROW', 22)),
ee.Filter.and(ee.Filter.eq('WRS_PATH', 208),         
              ee.Filter.eq('WRS_ROW', 23)),
ee.Filter.and(ee.Filter.eq('WRS_PATH', 208),         
              ee.Filter.eq('WRS_ROW', 24)),              
ee.Filter.and(ee.Filter.eq('WRS_PATH', 207),         
              ee.Filter.eq('WRS_ROW', 22)),              
ee.Filter.and(ee.Filter.eq('WRS_PATH', 207),         
              ee.Filter.eq('WRS_ROW', 23)),              
ee.Filter.and(ee.Filter.eq('WRS_PATH', 207),         
              ee.Filter.eq('WRS_ROW', 24)),
ee.Filter.and(ee.Filter.eq('WRS_PATH', 206),         
              ee.Filter.eq('WRS_ROW', 23)),
ee.Filter.and(ee.Filter.eq('WRS_PATH', 206),         
              ee.Filter.eq('WRS_ROW', 24))));

var c = l8.map(function(img) { return img.clip(my_geom); });

var withCloudiness = c.map(function(image) {
var cloud = ee.Algorithms.Landsat.simpleCloudScore(image).select('cloud');
var cloudiness = cloud.reduceRegion({
reducer: 'mean', 
geometry: my_geom, 
scale: 30,
});

return image.set(cloudiness);
});
var filteredCollection = withCloudiness.filter(ee.Filter.lt('cloud', 20));
print(filteredCollection);

So I have two problems:

1: When using Landsat 8, the code runs, but it does not filter based on a threshold, 20% in this case. When i write the output to a file it gives two columns, cloud_cover and cloud_cover_land, both have observations of cloud greater than 20%.

2: When I try using Landsat 5 or 7 my file is empty...but I know there are scenes that are below 20% cloud cover for Landsat 5.

What I am I doing wrong?

1

The problem is that simpleCloudScore wants a TOA image and you're passing it raw images. The fact that L8 does anything is simply coincidence.

var c = ee.ImageCollection('LANDSAT/LT05/C01/T1_TOA')
  .filterDate('1980-01-01', '2018-12-31')
  .filter(ee.Filter.rangeContains('WRS_PATH', 206, 208))
  .filter(ee.Filter.rangeContains('WRS_ROW', 22, 24))

var withCloudiness = c.map(function(image) {
  var cloud = ee.Algorithms.Landsat.simpleCloudScore(image).select('cloud');
  var cloudiness = cloud.reduceRegion({
    reducer: 'mean', 
    geometry: my_geom, 
    scale: 30,
  });

  return image.set(cloudiness);
});

var filteredCollection = withCloudiness.filter(ee.Filter.lt('cloud', 20));

print(withCloudiness.size())
print(filteredCollection.size());

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.