//Define first & last years of time series
var startyear = 2000;
var endyear = 2018;
var startmonth = 1;
var endmonth = 12;
// Compute beginning & end of study period + sequence of months & years
var startdate = ee.Date.fromYMD(startyear, startmonth, 1);
var enddate = ee.Date.fromYMD(endyear , endmonth, 30);
var years = ee.List.sequence(startyear, endyear);
var months = ee.List.sequence(startmonth,endmonth);
var TempCollection = ee.ImageCollection("MODIS/061/MOD11A2")
.select('LST_Day_1km')
.filterDate("startdate, enddate");
// Create LST composite for every month
var monthlyTemp = ee.ImageCollection.fromImages(
years.map(function (y) {
return months.map(function(m) {
var monthly = TempCollection
.filter(ee.Filter.calendarRange(y, y, "year"))
.filter(ee.Filter.calendarRange(m, m, "month"))
.mean();
return monthly
.set("year", y)
.set("month", m)
.set("system:time_start", ee.Date.fromYMD(y, m, 1));}); })
.flatten());
print (monthlyTemp, 'monthly Temp')// 228 images
var output_Monthly = monthlyTemp.filter(ee.Filter.listContains('system:band_names', 'constant').not())
.sort('system:time_start').toBands();
// MAX Value Composition
// Calculate mean values for each month over all years
var MonthlyMAX = ee.ImageCollection.fromImages(months
.map(function (m) {
var maxTemp = monthlyTemp
.filter(ee.Filter.eq("month", m))
// .select("")
.reduce(ee.Reducer.max())
.rename("max_Temp");
return maxTemp
.set("month", m);})
.flatten());
print (MonthlyMAX, 'MonthlyMAX'); //12 elements
// MIN Value Compisition
var MonthlyMIN = ee.ImageCollection.fromImages(months
.map(function (m) {
var minTemp = monthlyTemp
.filter(ee.Filter.eq("month", m))
.reduce(ee.Reducer.min())
.rename("min_Temp");
return minTemp
.set("month", m);})
.flatten());
print (MonthlyMIN, 'MonthlyMIN'); // 12 elements
var outputMIN = MonthlyMIN.filter(ee.Filter.listContains('system:band_names', 'constant').not())
.sort('system:time_start').toBands();
print(outputMIN,'min'); //11 bands
var outputMAX = MonthlyMAX.filter(ee.Filter.listContains('system:band_names', 'constant').not())
.sort('system:time_start').toBands();
print(outputMAX, 'max'); //11 bands
//Define first & last years of time series
var startyear = 2000;
var endyear = 2018;
var startmonth = 1;
var endmonth = 12;
// Compute beginning & end of study period + sequence of months & years
var startdate = ee.Date.fromYMD(startyear, startmonth, 1);
var enddate = ee.Date.fromYMD(endyear , endmonth, 30);
var years = ee.List.sequence(startyear, endyear);
var months = ee.List.sequence(startmonth,endmonth);
var TempCollection = ee.ImageCollection("MODIS/061/MOD11A2")
.select('LST_Day_1km')
.filterDate("startdate, enddate");
// Create LST composite for every month
var monthlyTemp = ee.ImageCollection.fromImages(
years.map(function (y) {
return months.map(function(m) {
var monthly = TempCollection
.filter(ee.Filter.calendarRange(y, y, "year"))
.filter(ee.Filter.calendarRange(m, m, "month"))
.mean();
return monthly
.set("year", y)
.set("month", m)
.set("system:time_start", ee.Date.fromYMD(y, m, 1));}); })
.flatten());
print (monthlyTemp, 'monthly Temp')// 228 images
var output_Monthly = monthlyTemp.filter(ee.Filter.listContains('system:band_names', 'constant').not())
.sort('system:time_start').toBands();
// MAX Value Composition
// Calculate mean values for each month over all years
var MonthlyMAX = ee.ImageCollection.fromImages(months
.map(function (m) {
var maxTemp = monthlyTemp
.filter(ee.Filter.eq("month", m))
// .select("")
.reduce(ee.Reducer.max())
.rename("max_Temp");
return maxTemp
.set("month", m);})
.flatten());
print (MonthlyMAX, 'MonthlyMAX'); //12 elements
// MIN Value Compisition
var MonthlyMIN = ee.ImageCollection.fromImages(months
.map(function (m) {
var minTemp = monthlyTemp
.filter(ee.Filter.eq("month", m))
.reduce(ee.Reducer.min())
.rename("min_Temp");
return minTemp
.set("month", m);})
.flatten());
print (MonthlyMIN, 'MonthlyMIN'); // 12 elements
var outputMIN = MonthlyMIN.filter(ee.Filter.listContains('system:band_names', 'constant').not())
.sort('system:time_start').toBands();
print(outputMIN,'min'); //11 bands
var outputMAX = MonthlyMAX.filter(ee.Filter.listContains('system:band_names', 'constant').not())
.sort('system:time_start').toBands();
print(outputMAX, 'max'); //11 bands