I want to control my NDVI trends with climate variables. Therefore I am using temperature, precipitation and soil moisture. But since my NDVI is in annual maximum I need to have the same format for the controlling. Therefore I try to calculate these annual max images for the climate bands. But when I then try to use these, the analysis is not working and giving me this error: Error in map(ID=1): Element.getNumber: Unable to cast value to Number.
This is the code to calculate the annual max images.
//Calc annual max for TerraClimate for Temp, soil and prec
var annual_max_temp = ee.ImageCollection(ee.List.sequence(1981, 2015).map(function (year){
var date_start = ee.Date.fromYMD(year, 1, 1);
var date_end = date_start.advance(1, "year");
return(ee.ImageCollection('IDAHO_EPSCOR/TERRACLIMATE')
.select(['tmmx','soil', 'pr'])
.filterDate(date_start, date_end)
.max()
.set({year: year, 'system:time_start':date_start})
.set({year: year, 'system:time_end':date_end}));
}));
And here is the complete code: https://code.earthengine.google.com/?scriptPath=users%2Fwelp1992%2FMaster%3ATemperature