3

I am trying to perform cloud masking of my study area, in Google Earth Engine, for LANDSAT-8 Tier 1 image collection, for my ROI. I found this interesting StackOverflow question which looks into this same issue. I used the same snippet of code for cloud removal, but unfortunately, the clouds of my ROI did not get cleared. Where did it go wrong?

This is the ROI

var ROI = 
    /* color: #d6d3d2 */
    /* displayProperties: [
      {
        "type": "rectangle"
      }
    ] */
    ee.Geometry.Polygon(
        [[[82.12628415166101, 17.03508764088917],
          [82.12628415166101, 16.499924353159972],
          [82.37484982548914, 16.499924353159972],
          [82.37484982548914, 17.03508764088917]]], null, false)
    

And this is the code snippet

//load images for composite
var sr14= ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
.filterBounds(ROI) //ROI
.filterDate('2019-03-01','2019-03-31')
//.select(['B4','B3','B2']); // if you select those bands you loose BQA band

// Temporally composite the images with a maximum value function.
var composite = sr14.max();
//Map.setCenter(35.8244, -3.5799);
var vis = {bands:['B4','B3','B2'],min:0, max:3000}

Map.addLayer(composite, vis, 'max value composite');

var mask = require('users/fitoprincipe/geetools:cloud_masks')

print(mask.help['landsatSR'])

var mask_function = mask.landsatSR() // mask function

var col_free = sr14.map(mask_function) // apply function to collection
var composite_free = col_free.max() // create composite using max

Map.addLayer(composite_free, vis, 'composite collection without clouds');

Here is the code

1 Answer 1

4

I just ran your code and the code is working as expected (masking the clouds in the cloud-free composite). You might want to use the inspector tool to confirm that the areas in the composites that look like clouds are indeed masked (see attached image). If you turn off the layers that have clouds in the map, you will see that the masked areas are transparent. That might be causing the confusion to think that clouds are not being masked.

image

2
  • Thankyou for you reply. But if those areas are transparent, shouldnt the land below it be visible? I want to perform classification after cloud masking. Will this not further hinder classification result?
    – Learner
    Mar 21, 2022 at 7:35
  • 1
    Remember that if there is a cloud in an image and you mask out those pixels, you will obtain an area with no data. Then, those gaps can be filled in with data from images acquired in different dates when doing a composite. In this case, the remaining no data areas represent areas where no pixel value was registered in the indicated time period (after masking clouds and shadows). I would suggest using a longer time period to filter the collection and perform the composite. Maybe that procedure lets you obtain an image without no data gaps. Mar 21, 2022 at 16:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.