1

I am trying to do supervised land use classification in a certain region. As this region is naturally prone to clouds, I have filtered the image collection on images with less than 10% cloud cover and afterwards I took the median image of the least clouded season to further remove influence of clouds and cloud shadows.

However, now, the quality of the image has reduced significantly, which makes it very difficult to use it for further land use classification. What could I change to obtain a cloud free image with less loss of image quality?

var collection = ee.ImageCollection('LANDSAT/LC08/C01/T1_RT_TOA')
  .filterBounds(aoi_2)
  .filterDate('2017-01-01', '2017-05-31')
  .sort('CLOUD_COVER')

var withcloud = collection.map(function(image){
  var cloud = ee.Algorithms.Landsat.simpleCloudScore(image).select('cloud');
  var cloudiness = cloud.reduceRegion({
    reducer: 'mean',
    geometry: aoi_2,
    scale: 30,
  });
  return image.set(cloudiness);
})  

var collection_filtered = withcloud.filter(ee.Filter.lt('cloud',10));
var image_median = collection_filtered.median();
Map.addLayer(image_median, {bands:['B4','B3','B2'], max:0.3}, 'median image');
1

You could use the Landsat 8 Surface Reflectance data, which contains a Fmask generated cloud mask in the pixel_qa band.

From the GEE example, adapted to your region:

var collection = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
    .filterDate('2017-01-01', '2017-05-31')
    .filterBounds(aoi_2)

// Function to cloud mask from the pixel_qa band of Landsat 8 SR data.
function maskL8sr(image) {
  // Bits 3 and 5 are cloud shadow and cloud, respectively.
  var cloudShadowBitMask = ee.Number(2).pow(3).int();
  var cloudsBitMask = ee.Number(2).pow(5).int();

  // Get the pixel QA band.
  var qa = image.select('pixel_qa');

  // Both flags should be set to zero, indicating clear conditions.
  var mask = qa.bitwiseAnd(cloudShadowBitMask).eq(0)
      .and(qa.bitwiseAnd(cloudsBitMask).eq(0));

  // Return the masked image, scaled to TOA reflectance, without the QA bands.
  return image.updateMask(mask).divide(10000)
      .select("B[0-9]*")
      .copyProperties(image, ["system:time_start"]);
}

var cloud_masked = collection.map(maskL8sr)

var image_median = cloud_masked.median()


Map.addLayer(image_median, {bands:['B4','B3','B2'], max:0.3}, 'median image');

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.