// บทเรียน Landsat data hand on // Code provided by Dr.Sitthisak Moukomla var Thailand = ee.FeatureCollection('USDOS/LSIB_SIMPLE/2017').filter(ee.Filter.eq('country_na', 'Thailand')); // Map.addLayer(Thailand); var collection = ee.ImageCollection('LANDSAT/LC09/C02/T1_L2') .filterDate('2023-12-01','2024-02-15') .filterBounds(Thailand) .sort('CLOUD_COVER') var c = collection.median(); // Applies scaling factors. function applyScaleFactors(image) { var opticalBands = image.select('SR_B.').multiply(0.0000275).add(-0.2); var thermalBands = image.select('ST_*.*').multiply(0.00341802).add(149.0); return image.addBands(opticalBands, null, true) .addBands(thermalBands, null, true); } var dataset = applyScaleFactors(c); var visualization = { bands: ['SR_B4', 'SR_B3', 'SR_B2'], min: 0.0, max: 0.25, }; var image = dataset.select(['SR_B2', 'SR_B3', 'SR_B4', 'SR_B5'], ['blue', 'green', 'red', 'nir']); // Extract VI band var NDVI = image.normalizedDifference(['nir', 'red']); var EVI = image.expression( "2.5 * ((nir - red) / (nir + 6 * red - 7.5 * blue + 1))", { 'nir' : image.select('nir'), 'red' : image.select('red'), 'blue': image.select('blue'), }); // Create palettes for display var pal = [ '040274', '040281', '0502a3', '0502b8', '0502ce', '0502e6', '0602ff', '235cb1', '307ef3', '269db1', '30c8e2', '32d3ef', '3be285', '3ff38f', '86e26f', '3ae237', 'b5e22e', 'd6e21f', 'fff705', 'ffd611', 'ffb613', 'ff8b13', 'ff6e08', 'ff500d', 'ff0000', 'de0101', 'c21301', 'a71001', '911003']; Map.addLayer(dataset.clip(Thailand), visualization, 'True Color (432)'); Map.addLayer(EVI.clip(Thailand), {min:0, max:1, palette: pal}, 'EVI'); Map.addLayer(NDVI.clip(Thailand), {min:0, max:1, palette: pal}, 'NDVI'); Map.centerObject(Thailand, 6);