2

I am a new Google Earth Engine user and I am trying to understand basic procedures/functions. More specifically, I want to remove clouds, cloud shadows and snow pixels form a Landsat 8 collection and then, calculate the NDVI. I have found the following sample code but I can not understand how to remove apart from the clouds, the cloud shadows and the snow. I think the Fmask might be he way to do this but I can not understand this.

Example code from Google Earth Engine API:

// This function masks clouds in Landsat 8 imagery.
var maskClouds = function(image) {
  var scored = ee.Algorithms.Landsat.simpleCloudScore(image);
  return image.updateMask(scored.select(['cloud']).lt(20));
};

// This function masks clouds and adds quality bands to Landsat 8 images.
var addQualityBands = function(image) {
  return maskClouds(image)
    // NDVI
    .addBands(image.normalizedDifference(['B5', 'B4']))
    // time in days
    .addBands(image.metadata('system:time_start'));
};

// Load a 2014 Landsat 8 ImageCollection.
// Map the cloud masking and quality band function over the collection.
var collection = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
  .filterDate('2014-06-01', '2014-12-31')
  .map(addQualityBands);

// Create a cloud-free, most recent value composite.
var recentValueComposite = collection.qualityMosaic('system:time_start');

// Create a greenest pixel composite.
var greenestPixelComposite = collection.qualityMosaic('nd');

// Display the results.
Map.setCenter(-122.374, 37.8239, 12); // San Francisco Bay
var vizParams = {bands: ['B5', 'B4', 'B3'], min: 0, max: 0.4};
Map.addLayer(recentValueComposite, vizParams, 'recent value composite');
Map.addLayer(greenestPixelComposite, vizParams, 'greenest pixel composite');
0

1 Answer 1

4

The example is outdated. Instead you can use the Landsat 8 Surface Reflectance collection LANDSAT/LC08/C01/T1_SR, which includes the pixel_qa band and allows you to filter the following classes:

Bit Attribute
- 0 Fill
- 1 Clear
- 2 Water
- 3 Cloud Shadow
- 4 Snow
- 5 Cloud
- 6-7 Cloud Confidence (00 = None, 01 = Low, 10 = Medium, 11 = High)
- 8-9 Cirrus Confidence (00 = None, 01 = Low, 10 = Medium, 11 = High)
- 10 Terrain Occlusion
0

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