Export composites

Create cloud free composites and store them as an asset

copy the code below

// filter province
var Gampaha = table.filter(ee.Filter.eq("NAME_1","??")).geometry();

var bandsIn = ee.List([1,2,3,4,5,6])
var bandsOut = ee.List(['blue','green','red','nir','swir1','swir2'])

// import imagecollection
var l8 = ee.ImageCollection("LANDSAT/LC08/C01/T1_SR");

// filter for location
l8 = l8.filterBounds(??);

// filter for date;
l8 = l8.filterDate("??","??");

function removeClouds(image){
  // get QA band
  var QA = image.select("pixel_qa");
  var shadow = QA.bitwiseAnd(8).neq(0);
  var cloud = QA.bitwiseAnd(32).neq(0);
  return image.updateMask(shadow.not()).updateMask(cloud.not());
}

l8 = l8.map(removeClouds);

var img = ee.Image(l8.median()).clip(Gampaha);
img = img.select(bandsIn,bandsOut)
Map.addLayer(img,{min:0,max:3000,bands:"??,??,??"});

Export.image.toAsset({image:img,
                      description:"2018_composite",
                      assetId:"yourname",
                      region:Gampaha.bounds(),
                      scale:30,
                      maxPixels:1e8})

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s