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:
- The code calculates the average temp for each day
- Subtracts 50 °F from the average temp for each day
- Sums up the total values of the output for a given time range
- 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);
Map.addLayer(
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.