// บทเรียน Air Temperature data by ECMWF Hand on // Code provided by Dr.Sitthisak Moukomla var c = ee.FeatureCollection('USDOS/LSIB_SIMPLE/2017').filter(ee.Filter.eq('country_na', 'Thailand')); //Map.addLayer(geometry); var dataset = ee.ImageCollection('ECMWF/ERA5_LAND/MONTHLY_AGGR') .select('temperature_2m'); // Use ee.Filter.calendarRange to filter by year and month var img = dataset.filter(ee.Filter.calendarRange(1981,2024,'year')) .filter(ee.Filter.calendarRange(3,3,'month')); // reduce image collection with mean() var mean = img.median().subtract(273.15); var vis = { bands: ['temperature_2m'], min: 10.0, max: 35.0, palette: [ "#000080","#0000D9","#4000FF","#8000FF","#0080FF","#00FFFF", "#00FF80","#80FF00","#DAFF00","#FFFF00","#FFF500","#FFDA00", "#FFB000","#FFA400","#FF4F00","#FF2500","#FF0A00","#FF00FF", ] }; Map.addLayer(mean.clip(c), vis, "Air temperature [K] at 2m height"); /* * Legend setup */ // Creates a color bar thumbnail image for use in legend from the given color // palette. function makeColorBarParams(palette) { return { bbox: [0, 0, 1, 0.1], dimensions: '100x10', format: 'png', min: 0, max: 1, palette: palette, }; } // Create the color bar for the legend. var colorBar = ui.Thumbnail({ image: ee.Image.pixelLonLat().select(0), params: makeColorBarParams(vis.palette), style: {stretch: 'horizontal', margin: '0px 8px', maxHeight: '24px'}, }); // Create a panel with three numbers for the legend. var legendLabels = ui.Panel({ widgets: [ ui.Label(vis.min, {margin: '4px 8px'}), ui.Label( (vis.max / 2), {margin: '4px 8px', textAlign: 'center', stretch: 'horizontal'}), ui.Label(vis.max, {margin: '4px 8px'}) ], layout: ui.Panel.Layout.flow('horizontal') }); var legendTitle = ui.Label({ value: 'Map Legend: Air temperature [C] at 2m height', style: {fontWeight: 'bold'} }); // Add the legendPanel to the map. var legendPanel = ui.Panel([legendTitle, colorBar, legendLabels]); Map.add(legendPanel); Map.centerObject(c,5.5); Map.setOptions('SATELLITE');