0

I have loaded a collection of landsat8 images bounded by sudanmaps. My goal is to filter out all images that have cloud in it. I tried the method given in Filter Landsat images base on cloud cover over a region of interest but I am getting following error

ImageCollection (Error)
Error in map(ID=LC08_170055_20130622):
Image.reduceRegion: Too many pixels in the region. Found 700331286, 
but only 10000000 allowed.

I guess this error is because of some threshold that limits the capability of google earth engine or maybe I am doing something wrong. Is there any alternate way to filter out the cloud images so as not to cross any threshold for google earth engine. Also, can we filter images based on BQA band ?. Below is my code: var sudanmap = ee.FeatureCollection("south_sudan_adm0");

var l8 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
.filterDate('2013-06-01', '2018-06-01').filterBounds(sudanmap);

var withCloudiness = l8.map(function(image) {
 var cloud = 
ee.Algorithms.Landsat.simpleCloudScore(image).select('cloud');
var cloudiness = cloud.reduceRegion({
reducer: 'mean', 
geometry: S_sudan, 
scale: 30,
});
return image.set(cloudiness);
 });
var filteredCollection = withCloudiness.filter(ee.Filter.lt('cloud', 10));
print(filteredCollection);
0

You need to check how Image.reduceRegion works. From documentation:

reduceRegion(reducer, geometry, scale, crs, crsTransform, bestEffort, maxPixels, tileScale)

Apply a reducer to all the pixels in a specific region. Either the reducer must have the same number of inputs as the input image has bands, or it must have a single input and will be repeated for each band. Returns a dictionary of the reducer's outputs.

Arguments:

this:image (Image): The image to reduce.

reducer (Reducer): The reducer to apply.

geometry (Geometry, default: null): The region over which to reduce data. Defaults to the footprint of the image's first band.

...

maxPixels (Long, default: 10000000): The maximum number of pixels to reduce.

Change this argument to avoid this error message:

var cloudiness = cloud.reduceRegion({
reducer: 'mean', 
geometry: S_sudan, 
scale: 30,
maxPixels: 1e10
});

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.