When I execute this expression:
var ETfraction = (Thot-LST)/(Thot-Tcold) // **pseudo code**
I get an error:
ee.ImageCollection(...).subtract is not a function
Why does this not work? Here is my code:
//Find Reference ET (ETo) from Terraclimate
var dataset = ee.ImageCollection('IDAHO_EPSCOR/TERRACLIMATE')
.filter(ee.Filter.date('2015-01-01', '2017-12-30'))
.map(function(image)
{return image.clip(basin)});
var pet = dataset.select('pet');
var pet = pet.map(function(img) {
return img
.multiply(0.1)
//.subtract(273.15)
.copyProperties(img, ['system:time_start']);
});
var vis = {
min: 50,
max: 200.0,
palette: [
'ffffff', 'fcd163', '99b718', '66a000', '3e8601', '207401', '056201',
'004c00', '011301'
],
};
Map.addLayer(pet,vis);
print(pet,'PET')
//Find LST from MODIS(MOD11A1.006 = Terar land surface temperature daily 1 km.)
var dataset = ee.ImageCollection('MODIS/006/MOD11A1')
.filter(ee.Filter.date('2015-01-01', '2017-12-30'))
.filterBounds(basin)
.map(function(image){return image.clip(basin)});
var lst = dataset.select('LST_Day_1km');
var lst = lst.map(function(img) {
return img
.multiply(0.02)
// .subtract(273.15)
.copyProperties(img, ['system:time_start']);
});
var landSurfaceTemperatureVis = {
min: 14000.0,
max: 16000.0,
palette: [
'blue', 'limegreen', 'yellow', 'darkorange', 'red'
],
};
//Ts=LST of each pixel
var monthly_lst = ee.List.sequence(0, 3*12)
.map(function(n)
{
// .sequence: number of years from starting year to present
var start = ee.Date('2015-01-01').advance(n, 'month'); // Starting date
var end = start.advance(1, 'month'); // Step by each iteration
return lst.filterDate(start, end)
.mean()
.set('system:time_start', start.millis());
});
var collection = ee.ImageCollection(monthly_lst);
//Thot = LST for the hot pixel
var Th_lst = ee.List.sequence(0, 3*12)
.map(function(n) {
// .sequence: number of years from starting year to present
var start = ee.Date('2015-01-01').advance(n, 'month'); // Starting date
var end = start.advance(1, 'month'); // Step by each iteration
return lst.filterDate(start, end)
.max()
.set('system:time_start', start.millis());
});
print(Th_lst);
var collection2 = ee.ImageCollection(Th_lst);
print(collection2,'Thot');
Map.addLayer(collection2,vis);
//Tcold = LST for the cold pixel
var Tc_lst = ee.List.sequence(0, 3*12)
.map(function(n) {
// .sequence: number of years from starting year to present
var start = ee.Date('2015-01-01').advance(n, 'month'); // Starting date
var end = start.advance(1, 'month'); // Step by each iteration
return lst.filterDate(start, end)
.min()
.set('system:time_start', start.millis());
});
print(Tc_lst);
var collection3 = ee.ImageCollection(Tc_lst);
print(collection3,'Tcold');
Map.addLayer(collection3,vis);
// // //ET fractional (ETf=(Thot-LST)/(Thot-Tcold))
var etf = ee.ImageCollection(Th_lst)
.subtract(ee.Image(monthly_lst))
.divide((ee.Image(Th_lst))
.subtract(ee.Image(Tc_lst)))
.rename('ETF').cast({'ETF': 'float'});
print(etf);
Map.addLayer(etf,vis);