//บทเรียน MODIS data Hand on //// Code provided by Dr.Sitthisak Moukomla // Define the region of interest: Thailand var thailand = ee.FeatureCollection('USDOS/LSIB_SIMPLE/2017') .filter(ee.Filter.eq('country_na', 'Thailand')); // Load MODIS Surface Reflectance Image Collection var modisSR = ee.ImageCollection('MODIS/061/MOD09GA') .filter(ee.Filter.date('2024-01-01', '2024-03-30')) .filterBounds(thailand); // Calculate NDWI using the formula (Green - NIR) / (Green + NIR) // Green band is 'sur_refl_b04' and NIR band is 'sur_refl_b02' var calculateNDWI = function(image) { var ndwi = image.normalizedDifference(['sur_refl_b04', 'sur_refl_b02']).rename('NDWI'); return image.addBands(ndwi); }; // Apply the NDWI calculation to the Image Collection var ndwiCollection = modisSR.map(calculateNDWI); // Select and visualize the NDWI band var ndwi = ndwiCollection.select('NDWI').median(); var ndwiVis = { min: -1.0, max: 1.0, palette: ['0000ff', '00ffff', 'ffff00', 'ff0000', 'ffffff'], }; // Center the map on Thailand and add the NDWI layer Map.centerObject(thailand, 5); Map.addLayer(ndwi.clip(thailand), ndwiVis, 'NDWI Colorized');