I'd like to filter a large collection of Landsat 5 Surface Reflectance images by cloud cover within a small region of interest (not the entire image scene) in Google Earth Engine. I know there are ways of accomplishing this using TOA reflectance, but so far I have not found any solutions for SR imagery.

I have applied a cloud mask, however that often results in images that are 90% masked out in my ROI and are basically useless. I'd like to avoid downloading such images in the first place.

1 Answer 1


You have to map a reduceRegion over the collection to compute a cloud score for your ROI, store than on each image, then sort/filter on that value. You can compute the cloud score by just counting the pixels in the cloud mask from the Landsat 457 Surface Reflectance example in the code editor, or by using the Simple Cloud Score example to find clouds (you'll have to change the bands).

That said, it probably won't be fast and you're likely to have to either run it in pieces or as an Export to produce a list of acceptable image IDs.

Doing that (exporting a list of scene IDs) is probably the best option because it would then let you script a whole bunch of getDownloadUrl calls, in parallel (up to 20), which would be much faster (~10x) than doing the same number of Exports.

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.