google-earth-enginelandsat

how cloud masking is done on Landsat 8 surface reflectance data in Google earth engine?


I want to download cloud-masked Landsat 8 surface reflectance collection from google earth engine. I don't have any idea how to perform a cloud masking algorithm. here's my code:

Map.centerObject(table);
Map.addLayer(table);

var sur = ee.ImageCollection.load('LANDSAT/LC08/C01/T1_SR')
.filterBounds(table)
.filterDate('2013-01-01','2019-11-01')
.filter(ee.Filter.equals('WRS_PATH',15))
.filter(ee.Filter.equals('WRS_ROW',33))
.filter(ee.Filter.lt('CLOUD_COVER', 5))
//.filter(ee.Filter.equals('IMAGE_QUALITY',4))
//.filter(ee.Filter.rangeContains('CLOUD_COVER',15,45));
.filter(ee.Filter.lt('CLOUD_COVER_LAND', 5));
print(sur);

// list of images (client side)
var imColl_sur = sur.getInfo().features;
print('features: ', imColl_sur);
print('length: ', imColl_sur.length);

// loop on client side
for (var i = 0; i < imColl_sur.length; i++) {
  var id = imColl_sur[i]["id"];
  var im = ee.Image(id);
  var clip = im.clip(table);
  var b1 = clip.select('B1');
  var D_T = imColl_sur[i]["properties"]["SENSING_TIME"];
  var sza = (imColl_sur[i]["properties"]["SOLAR_ZENITH_ANGLE"]).toString();
  Export.image.toDrive({
    image: b1,
    description: id.slice(8, 12)+"_surReflectance_B1_"+ id.slice(28, 34) +"_"+ D_T.slice(0,4)+D_T.slice(5,7)+D_T.slice(8,10) + "_" + D_T.slice(11,13)+D_T.slice(14,16) + "_" + sza.slice(0,2)+sza.slice(3,8),
    scale: 30,
    region : table,
    maxPixels : 1e9
  });
}

thanks


Solution

  • You should check out this example provided by the Earth Engine team: https://code.earthengine.google.com/?scriptPath=Examples:Cloud%20Masking/Landsat8%20Surface%20Reflectance

    This script uses the pre-computed Landsat 8 QA band from CFMask to remove clouds and cloud shadows.