Wednesday 28 February 2018

google earth engine - How to apply a Cloud Mask in a collection?


I am trying to apply a mask cloud in a SAVI collection (LANDSAT) to get a chart with time variations between pixels.


var region = table3


Map.addLayer(table3)

var col = ee.ImageCollection('LANDSAT/LE7_SR')
.filterDate('2004-01-01', '2011-12-31')
.filterBounds(table3)
.filter(ee.Filter.eq('WRS_PATH', 1))
.filter(ee.Filter.eq('WRS_ROW', 72));

print(col)


// Mask clouds
var col_noclouds = col.map(function(img) {
var mask =
img.select(['cfmask']).neq(4).neq(1).neq(2).neq(3)
return img.updateMask(mask)
})

// Median image
var medians = ee.Image(col_noclouds.median())


var clipper = medians.clip(table3)


// A function to compute Soil Adjusted Vegetation Index.
var SAVI = function(image) {
return clipper.expression(
'(1 + L) * float(nir - red)/ (nir + red + L)',
{
'nir': image.select('B5'),

'red': image.select('B4'),
'L': 0.5
}).set('system:time_start', image.get('system:time_start'));
};

// Shared visualization parameters.
var vis = {
min: 0,
max: 1,
palette: [

'FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718',
'74A901', '66A000', '529400', '3E8601', '207401', '056201',
'004C00', '023B01', '012E01', '011D01', '011301'
]
};


var image = ee.ImageCollection(col)
.map(SAVI);


print(image)

Map.addLayer(image,vis);


var TS5 = Chart.image.seriesByRegion(image, region,
ee.Reducer.mean(),'constant', 500, 'system:time_start').setOptions({
title: 'NDVI Long-Term Time Series',
vAxis: {title: 'constant'},
});

print(TS5);

I can make the chart for "image" (collection with SAVI function) but I do not know how to insert the cloud mask.


Any recommendation?




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...