# Using accumulate function for temperature units?

I am working on a piece of code that is designed to aggregate growing degree days for a particular region.

To start, the equation for growing degree days is: Daily GDD (°F) = Daily Average Temperature °F - 50 °F

So I am trying to compile a function for MODIS data where:

1. The code calculates the average temp for each day
2. Subtracts 50 °F from the average temp for each day
3. Sums up the total values of the output for a given time range
4. Places that value on the map

The goal being that when looking at different areas throughout a given time range on a map, you will see variations in the total heat units accumulated.

Here is my code

``````var dataset = ee.ImageCollection('MODIS/006/MYD11A2')
.filter(ee.Filter.date('2015-04-01', '2015-05-20'));
var landSurfaceTemperature = dataset.select('LST_Day_1km');
var landSurfaceTemperatureVis = {
min: 13250.0,
max: 15690.0,
opacity: .46,
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'
],
};
Map.setCenter(-85.60371794450282,44.73590436363271, 10);
landSurfaceTemperature, landSurfaceTemperatureVis,
'Land Surface Temperature');
// Create a geometry representing an export region.
var features = ee.Geometry.Rectangle([-85.1417893413635, 45.31413490213395, -86.125065708551, 44.65070625463291]);

// Export a cloud-optimized GeoTIFF.
Export.image.toDrive({
image: landSurfaceTemperatureVis,
description: 'imageToCOGeoTiffExample',
scale: 30,
region: features,
fileFormat: 'GeoTIFF',
formatOptions: {
cloudOptimized: true
}
});
``````

I am completely lost as to A. how to average & subtract x from each day within given time range, and B. how to accumulate those values onto a map.

• Do you have example reports where this is done for MODIS data? I think the MODIS product you are referring to does not provide multiple temperature measures a day at a location and therefore a daily mean temperature cannot be provided as input for your formula.
– Kuik
Mar 19, 2019 at 23:10
• I do believe MODIS only takes a reading at 10:17 am over the area in which I am currently working. If I could find a geostationary asset or a compiled dataset of satellite and ground stations that would provide a daily average for a large coverage area, I would like to use that resource. Unfortunately I have come up short in my hunt for a true daily max/min. However, if it's at 10:17 am everyday, that's okay with me. I'm really just looking to structure the actual temperature calculation. Mar 20, 2019 at 1:14

I am not sure if this data is valid input for your calculations. That said, what you describe as the Growing Degree Days can be done in the GEE as follows:

``````// 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());
// Mask where one of Night or day temperature has no data
// we assume that the night temperature is the min temp, and the day temperature is the max temperature
// Calculate the GGD
var GDD = meanFahr.subtract(50).rename('GDD');
var GDDnonNeg = GDD.where(GDD.lt(0), 0).rename('GDDnonNeg');
});

// calculate the sum of GGD values
var summed = tempToFahr.select('GDDnonNeg').sum().rename('summedGDD');
``````