I'm trying to convert Kelvin to Celsius in MODIS LST product in Google Earth Engine. But there is an error in my code. The code is:
var LST_K = ee.ImageCollection('MODIS/006/MOD11A2')
.filterBounds(AOI)
.filterDate('2021-02-20','2021-05-31')
.select("LST_Day_1km","LST_Night_1km")
.map(function(img){
return img.multiply(0.02)
.copyProperties(img,['system:time_start','system:time_end']);
});
print(LST_K);
// convert LST to celcius
var toCelsius = function(img){
var time = img.get('system:time_start')
var celsius = img.multiply(0.02) // scale factor
.subtract(273.15) // from kelvin to C
.rename('Celcius')
.set('system:time_start',time)
return celsius;
};
var LST = LST_K.map(toCelsius)
print(LST);
print(ui.Chart.image.series(LST, AOI, ee.Reducer.median(), 1000, 'system:time_start'));
and the link code is below: https://code.earthengine.google.com/61b7668525bd38cd543f72c0ad201886
Many thanks in advance