Skip to main content
4 of 4
Shifted initial paragraph to body; English usage; entitled
Vince
  • 20.3k
  • 16
  • 48
  • 65

Capture monthly yearly change temperature from CSV in GEE

I did not receive any data from change temperature CSV from my code. How can I correct it?

I need to export monthly yearly change temperature in single CSV but I did not receive any data in my CSV.

How can I solve it?

//var regions = table.filterBounds(geometry);
var regionNames = ee.List([
  '1','2','3','4','5','6','7','8','9','10','11','12','13'
  ,'14','15','16','17','18','19','20','21','22'
]);
var regions = table.filterBounds(geometry)
  .map(function (region) {
    var index = region.getNumber('FID_1');
    return ee.Feature(region.geometry(), {
      'Region ID': index,
      'Region Name': regionNames.get(index)
    });
  });
  
Map.addLayer(regions);
var clipToCol = function(image){
  return image.clip(regions);
};
var change_c = ee.ImageCollection('MODIS/061/MOD11A2')
.filterDate(ee.Date('2001-01-01'), ee.Date('2022-01-01'))
.filterBounds(geometry)
.map(clipToCol);


var months = ee.List.sequence(1, 12);
var years = ee.List.sequence(2001, 2022);

var change= change_c.map(function(image) {
  return image.multiply(0.02).copyProperties(image,['system:time_start']);
});

var changeByMonthYear = ee.ImageCollection.fromImages(
  years.map(function(y) {
    return months.map(function (m) {
       var median = change
      return change
        .filter(ee.Filter.calendarRange(y, y, 'year'))
        .filter(ee.Filter.calendarRange(m, m, 'month'))
        .median()
        .set('month', m).set('year', y);
         return median
        .set('empty',  median.bandNames().size().eq(0));
  });
}).flatten());
var selectors = ['Region ID', 'Region Name', 'year', 'month', 'ndvi'];

var byRegion = changeByMonthYear
  .filter(ee.Filter.eq('empty', 0)) // Remove year/month without imagery
  .map(function(yearMonthchange) {
    return yearMonthchange
      .reduceRegions({
        collection: regions,
        reducer: ee.Reducer.median().setOutputs(['changetemp']), 
        scale: 500
        
      })
      .map(function (feature) {
        return feature
          .copyProperties(yearMonthchange, yearMonthchange.propertyNames());
      });
  })
  .flatten()
  .select(selectors);
Export.table.toDrive({
  collection: byRegion,
  description: 'changetemp',
  selectors: ['region', 'year', 'month', 'changetemp']
});

This is my link code: https://code.earthengine.google.com/13515dc5d295ecd2a3e3bdf2e495adab