0

I am using the code below that was originally provided by @Kuik, and I have since converted the bands to DAYMET 'tmax' and 'tmin' bands.

Problem is that when I run the code, I receive no output. What am I doing wrong?

var dataset = ee.ImageCollection('NASA/ORNL/DAYMET_V3')
                  .filter(ee.Filter.date('2015-04-01', '2015-05-20'));
var landSurfaceTemperature = dataset.select(['tmin', 'tmax']);

// Create a geometry representing an export region.
var features = ee.Geometry.Rectangle([-85.1417893413635, 45.31413490213395, -86.125065708551, 44.65070625463291]);

// ######### ADDED CODE ############

// 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('tmax')).updateMask(Fahr.select('tmin'));
  // 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(50).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');


// ######### END ADDED CODE ############

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'
  ],
};
Map.setCenter(-85.60371794450282,44.73590436363271, 10);
Map.addLayer(summed, {min: 0, max: 50, palette: landSurfaceTemperatureVis.palette},'summed growing degree days', 1, 1);


// Export a cloud-optimized GeoTIFF.
Export.image.toDrive({
  image: summed,
  description: 'imageToCOGeoTiffExample',
  scale: 1000,
  region: features,
  fileFormat: 'GeoTIFF',
  formatOptions: {
    cloudOptimized: true
  }
});
  • (image.multiply(0.02).subtract(273.15)) is not needed cause this dataset already has temperature in Celcius. Eliminating that seems to work. – Kuik Mar 27 at 7:53
  • I removed that line entirely, however there are many more lines that are contingent on the var "Fahr". I have tried a number of combinations to try and switch out those fields, but none have worked. How do I remove that line and still make the code work? – Joey Roses Mar 29 at 18:44
  • Literally, only remove '(image.multiply(0.02).subtract(273.15))'. Replace that with image. Thus it will become: var Fahr = image.multiply(1.8).add(32); to make celcius into fahrenheit – Kuik Mar 29 at 20:36
  • You are the man! Thank you. – Joey Roses Mar 30 at 22:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.