-1

I want to take out snow and use a less cloud Landsat image. I am not sure the code from var image.... I think this is the right order (filterData, sort, median and map) but it does not work.

function maskL8sr(image) {
  // Bits 3 and 5 are cloud shadow and cloud, respectively.
  var cloudShadowBitMask = (1 << 3);
  var cloudsBitMask = (1 << 5);
  var snowBitMask = (1 << 4);
  var waterBitMask = (1 << 2);

  // 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(snowBitMask).eq(0);
return image.updateMask(mask);
}


var image = ee.Image(ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
    .filterDate('2018-01-01', '2018-12-31')
    .map(maskL8sr) 
    .sort('CLOUD_COVER')
    .median());
1
  • You say "it does not work" but precisely what happens when you try the code that you have presented? – PolyGeo Nov 21 '19 at 5:32
0

As suggested it would help if you explain in more detail what you have in mind and what you tried. If you want ice you could for example use a index and thresholding as a start:

function maskL8sr(image) {
  // Bits 3 and 5 are cloud shadow and cloud, respectively.
  var cloudShadowBitMask = (1 << 3);
  var cloudsBitMask = (1 << 5);
  var snowBitMask = (1 << 4);
  var waterBitMask = (1 << 2);

  // 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(snowBitMask).eq(0);
return image.updateMask(mask);
}


var image = ee.Image(ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
    .filterDate('2018-01-01', '2018-12-31')
    .filter(ee.Filter.lte('CLOUD_COVER',20)) // filter on Cloud Cover
    .map(maskL8sr) 
    .sort('CLOUD_COVER')
    .filterBounds(geometry)
    .median())

var ndsi      = image.normalizedDifference(['B5','B6']);                  // snow/ice index

print(image, 'image')

Map.addLayer(image, {min:150, max: 15000, bands:['B5', 'B3', 'B2']}, 'image')
Map.addLayer(ndsi, {min:-0.4, max: 0.8, palette: ['darkred','yellow','green','blue','darkblue']}, 'NDSI image')

// classifation
var ndsithresh   = 0.25;
var debris = ndsi.lt(ndsithresh)
var ice = debris.eq(0);

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.