2

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");

1 Answer 1

1

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.

2
  • Yes that's what they say but the USGS Landsat 8 Surface Reflectance metadata says: These data have been atmospherically corrected using LaSRC, and includes a cloud, shadow, water and snow mask produced using CFMASK, as well as a per-pixel saturation mask. Commented Feb 7, 2018 at 11:53
  • Well done. If you want you could accept the answer.
    – gtapko
    Commented Feb 7, 2018 at 13:00

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.