Saturday 20 October 2018

google earth engine - Landsat mosaic with minimum cloud cover over an area of interest


I'd like to create a mosaic with minimum cloud cover over an area of interest. I have done this by using the sort function to return the image with minimum 'CLOUD_COVER' value and am happy with the result.


// Find image at point with least cloud cover in the year 2014


// imported // landsat = 'USGS Landsat 8 Raw Scenes (Orthorectified)'

var trueColor= {
bands: ['B4','B3','B2'],
min: 5000,
max: 15000,
};

var point = ee.Geometry.Point([116.64,8.26])


var image = ee.Image(landsat.filterDate('2014-01-01','2014-12-31')
.filterBounds(point).sort('CLOUD_COVER').first());

Map.addLayer(image,trueColor,'True Color Image')

enter image description here


I would like to extend this to a wider area but it seems I cannot use the sort function on an imageCollection in this way. I have tried to use a cloud filter function as detailed in this answer, however the result is extremely cloudy Filter Landsat images base on cloud cover over a region of interest


// Find images within an area with least cloud cover in the year 2014


// imported // landsat = 'USGS Landsat 8 Raw Scenes (Orthorectified)'

var trueColor= {
bands: ['B4','B3','B2'],
min: 5000,
max: 15000,
};

var polygon = ee.Geometry.Polygon([
[[116.64,8.26], [119.41,8.26], [119.41,10.44], [116.64,10.44],[116.64,8.26]]

]);

var collection = ee.ImageCollection(landsat.filterDate('2014-01-01','2014-12-31').filterBounds(polygon));

var withCloudiness = collection.map(function(image) {
var cloud = ee.Algorithms.Landsat.simpleCloudScore(image).select('cloud');
var cloudiness = cloud.reduceRegion({
reducer: 'mean',
geometry: polygon,
scale: 30,

maxPixels: 1e9
});
return image.set(cloudiness);
});

var filteredCollection = withCloudiness.filter(ee.Filter.lt('cloud', 10));

Map.addLayer(filteredCollection.mosaic(), trueColor, 'spatial mosaic');

enter image description here





No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...