TransWikia.com

Cloud mask error: Pattern 'cfmask' did not match any bands

Geographic Information Systems Asked by Vânia Borges on September 26, 2021

I want to “replace” the values of the cloud pixels for: it could be a mean, to calculate pre and pos-date NDVI for one country.
I’ve used the code of a previous answer:
Mask clouds in LandSat 8 surface refletance image

But this is giving error:

ImageCollection (Error)
Error in map(ID=LC08_202033_20170804):
Image.select: Pattern 'cfmask' did not match any bands. 

What am I doing wrong?

The code:

//Choose country using GEE Feature Collection

var region = ee.FeatureCollection('ft:1tdSwUL7MVpOauSgRzqVTOwdfy17KDbw-1d9omPw').filterMetadata('Country', 'equals', 'Portugal');

//Add region outline to layer ‐ for selected countries

Map.addLayer(region,{}, 'Portugal');


// image collection pre 11/10/2017

var lt8_pre = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
  .filterBounds(region) 
  .filterDate(ee.Date("2017-08-01"),ee.Date("2017-10-11")); 

var lt8_ndvi_pre = lt8_pre
  .map(function(img){  
  return img.addBands(img.normalizedDifference(['B4', 'B5'])).updateMask(img.select(['cfmask']).neq(4));
  });

print(lt8_ndvi_pre);

Map.centerObject(region, 10);
var ndvi_viz = {min:-0.8, max:0.3, palette:'000000,00FF00'};
Map.addLayer(lt8_ndvi_pre.select('nd').mean(), ndvi_viz, "LT8 2017 NDVI mean pre 11/10");

One Answer

According your dataset description, there is not a cfmask in the selected collection, see: Google Earth Engine Datasets Metadata

In order to solve the issue you could change to a collection with cfmask or use the BQA band for filtering clouds.

Correct answer by gtapko on September 26, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP