I am doing some GDD data analysis for a project and am having trouble coming up with a way to effectively analyze a specific time of the season over multiple years.
What I am trying to do is find what areas accumulate GDD and what areas don't during a critical period of fruit production over a period of multiple years.
I have the code below (which does the calculations for GDD), but i am stuck on how to run that calculation for each filter date that I have set (04-15-xx, 05-15-xx) and then either sum or average the image outputs.
This works for an individual year (by replacing ".map(ClipToCol)" with the filterDate function, but i want to average or sum multiple years.
Ideas?
// This function clips images to the ROI feature collection
var clipToCol = function(image){
return image.clip(geometry);
};
var dataset = ee.ImageCollection('MODIS/006/MYD11A1')
.map(clipToCol);
var landSurfaceTemperature = dataset.select(['LST_Day_1km', 'LST_Night_1km']);
// According to: https://gis.stackexchange.com/questions/307548/getting-temperature-data-of-given-point-using-modis-lst-data
// map over the image collection and use server side functions
var tempToFahr = landSurfaceTemperature.map(function(image){
var props = image.toDictionary(image.propertyNames());
var Fahr = (image.multiply(0.02).subtract(273.15)).multiply(1.8).add(32);
// Mask where one of Night or day temperature has no data
var FahrMasks = Fahr.updateMask(Fahr.select('LST_Day_1km')).updateMask(Fahr.select('LST_Night_1km'));
// we assume that the night temperature is the min temp, and the day temperature is the max temperature
var meanFahr = FahrMasks.reduce('mean').rename('meanTemp');
// Calculate the GGD and make all the negative values 0 (see: https://en.wikipedia.org/wiki/Growing_degree-day)
var GDD = meanFahr.subtract(52.5).rename('GDD');
var GDDnonNeg = GDD.where(GDD.lt(0), 0).rename('GDDnonNeg');
return ee.Image(Fahr.addBands([meanFahr, GDD, GDDnonNeg]).setMulti(props));
});
// calculate the sum of GGD values
var summed = tempToFahr.select('GDDnonNeg').sum().rename('summedGDD');
var landSurfaceTemperatureVis = {
min: 0,
max: 100,
bands: ['LST_Day_1km'],
palette: [
'040274', '040281', '0502a3', '0502b8', '0502ce', '0502e6',
'0602ff', '235cb1', '307ef3', '269db1', '30c8e2', '32d3ef',
'3be285', '3ff38f', '86e26f', '3ae237', 'b5e22e', 'd6e21f',
'fff705', 'ffd611', 'ffb613', 'ff8b13', 'ff6e08', 'ff500d',
'ff0000', 'de0101', 'c21301', 'a71001', '911003'
],
};