var dataset = ee.FeatureCollection("users/mpangihutan/Jawa Tengah");
function maskS2clouds(image) {
var qa = image.select('ST_ATRAN');
// Bits 10 and 11 are clouds and cirrus, respectively.
var cloudBitMask = 1 << 10;
var cirrusBitMask = 1 << 11;
// Both flags should be set to zero, indicating clear conditions.
var mask = qa.bitwiseAnd(cloudBitMask).eq(0)
.and(qa.bitwiseAnd(cirrusBitMask).eq(0));
return image.updateMask(mask).divide(10000);
}
// Load Landsat LC08 reflectance data.
var lc8 = ee.FeatureCollection('LANDSAT/LC08/C01/T1_SR')
.filterDate('2013-01-01', '2013-12-31')
.filter(ee.Filter.lt('CLOUD_COVER',30))
.map(maskS2clouds)
.filter(ee.Filter.bounds(roi));
var visualization = {
bands: ['SR_B4', 'SR_B3', 'SR_B2'],
min: 0.0,
max: 0.3,
};
// Proses Landsat LC08
var image = dataset.median();
var clipped = image.clip(roi)
var ndwi = clipped.normalizedDifference(['B3', 'B11']).rename(['ndwi']);
var tss = clipped.expression(
"(ndwi > 0.1) ? 8.1429 * pow(VNIR,23.704* 0.94* Bandred))"+
": 0",{
'ndwi' : ndwi,
'VNIR': image.select('B7')
}).rename('tss');
var palete = ['blue','yellow','red','brown']
//print(maxTSS)
var vizTSS = {
min: 1,
max: 120,
palette: palete
}
function createColorBar(titleText, palette, min, max) {
// Legend Title
var title = ui.Label({
value: titleText,
style: {fontWeight: 'bold', textAlign: 'center', stretch: 'horizontal'}});
// Colorbar
var legend = ui.Thumbnail({
image: ee.Image.pixelLonLat().select(0),
params: {
bbox: [0, 0, 1, 0.1],
dimensions: '200x20',
format: 'png',
min: 0, max: 1,
palette: palette},
style: {stretch: 'horizontal', margin: '8px 8px', maxHeight: '40px'},
});
// Legend Labels
var labels = ui.Panel({
widgets: [
ui.Label(min, {margin: '4px 10px',textAlign: 'left', stretch: 'horizontal'}),
ui.Label((min+max)/2, {margin: '4px 20px', textAlign: 'center', stretch: 'horizontal'}),
ui.Label(max, {margin: '4px 10px',textAlign: 'right', stretch: 'horizontal'})],
layout: ui.Panel.Layout.flow('horizontal')});
// Create a panel with all 3 widgets
var legendPanel = ui.Panel({
widgets: [title, legend, labels],
style: {position: 'bottom-left', padding: '8px 15px'}
})
return legendPanel
}
// Call the function to create a colorbar legend
var colorBar = createColorBar('Total Suspended Soil / TSS - mg/liter', palete, 0, 120)
// Tayang peta2
//Map.addLayer(ndti, {}, 'NDTI');
//Map.addLayer(ndwi, {}, 'NDWI');
Map.add(colorBar)
Export.image.toDrive({
image: TSS_Masked,
description: "tss",
scale: 30,
region: roi
})
roi
, perhaps it's only showing up for some specific area. Update your question and include it.