Landat composite from least clouded images

create cloud free composites

The code below takes the image with least cloud cover from each path and row specified in the list. see an example here.

// function to get lowest cloud cover per path and row
function getLowestCC (pathrow) {
pathrow = ee.List(pathrow);

var myImages = collection
.filterMetadata('WRS_PATH', "equals", pathrow.get(0))
.filterMetadata('WRS_ROW', "equals", pathrow.get(1))
.sort('CLOUD_COVER', true);

var image = ee.Image(myImages.first());

return image;

// import the image collection
var collection = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR');
// set the path and row
var pathrow = ee.List([[173.0, 37.0],[173.0, 38.0],[173.0, 39.0],[174.0, 36.0],[174.0, 37.0],[174.0, 38.0],[174.0, 39.0],[174.0, 40.0],[175.0, 37.0],[175.0, 38.0], [175.0, 39.0]]);

// get the cloud free image from each path and row
var images = ee.ImageCollection(;

// add the image to the map
Map.addLayer(images.mosaic(),{bands:['B4','B3','B2'], min:0, max:3000});

Leave a Reply

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

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

Facebook photo

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

Connecting to %s