I am trying to get cloud-free imagery for a specific region during specific dates. I am very new to GEE, but the script below seems to work. However when I look at the imagery that is then printed on the map, all images are black. I've checked and the RGB is correct.

What am I doing wrong?

// A rectangle representing the roi.
var geometry = ee.Geometry.Rectangle(-8.372, 10.017, -2.703, 5.358)

var ic = ee.ImageCollection("LANDSAT/LC08/C01/T1_TOA")

    var c = ic.filterBounds(geometry);

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

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

// Compute the median in each band, in each pixel.
//var median = filteredCollection.median();


// Select the red, green and blue bands.
//var filteredCollection = median.select('B3', 'B2', 'B1');
var visParams = {bands: ['B4', 'B3', 'B2'], max:0.4};
Map.setCenter(-6.01, 6.51, 5);

1 Answer 1


This a common mistake, since you're new in GEE, maybe you didn't notice it. Once created the visParams object, needs to be called from Map.addLayer() function:


I recommend you to stretch a bit the visualization range:

var visParams = {bands: ['B4', 'B3', 'B2'],min:0,max:0.25};
Map.addLayer(filteredCollection, visParams);

By the way, there are better options to create what you wanna do. For example, to mask cloud and to apply a reducer (like median or min)


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.