var roi = table;
var modisLST = ee.ImageCollection('MODIS/061/MOD11A1')
.filterBounds(roi)
.filterDate('2000-01-01', '2024-12-31')
.select(['LST_Day_1km', 'LST_Night_1km']);
function calculateLSTDifference(image) {
var lstDay = image.select('LST_Day_1km').multiply(0.02).subtract(273.15);
var lstNight = image.select('LST_Night_1km').multiply(0.02).subtract(273.15);
return image.addBands(lstDay.subtract(lstNight).rename('LST_Difference'));
}
var modisLSTWithDifference = modisLST.map(calculateLSTDifference);
function computeLSTDifference(startDate, endDate) {
var data = modisLSTWithDifference.filterDate(startDate, endDate);
return data.select('LST_Difference').mean().clip(roi).set('system:time_start', startDate.millis());
}
var monthlyLSTDifference = ee.ImageCollection(
ee.List.sequence(2000, 2024).map(function(year) {
return ee.List.sequence(1, 12).map(function(month) {
return computeLSTDifference(ee.Date.fromYMD(year, month, 1), ee.Date.fromYMD(year, month, 1).advance(1, 'month'));
});
}).flatten()
);
var yearlyLSTDifference = ee.ImageCollection(
ee.List.sequence(2000, 2024).map(function(year) {
return computeLSTDifference(ee.Date.fromYMD(year, 1, 1), ee.Date.fromYMD(year, 1, 1).advance(1, 'year'));
})
);
function plotLSTChart(imageCollection, title, xAxisTitle) {
return ui.Chart.image.series({
imageCollection: imageCollection,
region: roi,
reducer: ee.Reducer.mean(),
scale: 1000
}).setOptions({
title: title,
hAxis: {title: xAxisTitle},
vAxis: {title: 'LST Difference (°C)'},
lineWidth: 2,
colors: ['black'],
pointSize: 3
});
}
print(plotLSTChart(monthlyLSTDifference, 'Monthly Land Surface Temperature Difference (LST Day - LST Night)', 'Month'));
print(plotLSTChart(yearlyLSTDifference, 'Annual Land Surface Temperature Difference (LST Day - LST Night)', 'Year'));