1

I'm trying to clip and export climate data (annual max) from one ImageCollection to an already existing table with (annual max) NDVI values and clip them with conflict points stored in FeatureCollection. The script works for the NDVI, which I have as an asset in GEE. But since I'm creating annual max images in the script without saving them as an Asset, I have problems to use it.

//Calc annual max for TerraClimate for Temp, soil and prec and clip with conflicts 25
var annual_max_temp =  ee.ImageCollection(ee.List.sequence(1981, 2015).map(function (year){
  var date_start = ee.Date.fromYMD(year, 1, 1); 
  var date_end = date_start.advance(1, "year");

  return(ee.ImageCollection('IDAHO_EPSCOR/TERRACLIMATE')
        .select(['tmmx','soil', 'pr'])
        .filterDate(date_start, date_end)
          .max()
          .set({year: year, 'system:time_start':date_start.millis()}) 
          .set({year: year, 'system:time_end':date_end.millis()}));
}));

print(annual_max_temp,'at');
Map.addLayer(annual_max_temp,{color: '0036FF', pointRadius: 6}, 'at');

//Clipping the Climate IC with the Conflict FC and adding them to the NDVI_Slopes_Table
var GIMMSConfl25 = NDVI_Slopes
  .map(function(f) {
    var maxNDVI = annual_max_temp //when I use this it works: var maxNDVI = ee.ImageCollection('users/welp1992/GIMMS_Max_Annual_NDVI')
                      .filterDate('1982-01-01', '2015-12-31')
                      .map(function(img) {return img.clip(Conf25)})
                      (['tmmx','soil', 'pr']) 
      .map(function(img) {
        var d = img.reduceRegion({
                    reducer: ee.Reducer.first(), 
          geometry: f.geometry(),
          scale: 8000
        });
        return f.set(d).set('GIMMSdate', img.date().format('yyyyMMdd')); 
      });
    
    return maxNDVI; //global variable, use later in script
    
  }).flatten(); 
  
// Get Info
//print(NDVI_Slopes.limit(650));
print('Annual_Max_Clipped',Annual_Max_Clipped.limit(650));
print('Annual_Max_Clipped',Annual_Max_Clipped.size())

Export.table.toDrive({
  collection: GIMMSConfl25,
  description: 'annual_max_temp_table',
  fileFormat: 'CSV'
});

I get this error. annual_max_temp.filterDate(...).map(...) is not a function

How do I replace the ImageCollection in the code? I think it's a simple problem in the code. But if needed I can share the code and the assets.

2

This problem is a matter of JavaScript syntax. In this section of the code

    var maxNDVI = annual_max_temp
                      .filterDate('1982-01-01', '2015-12-31')
                      .map(function(img) {return img.clip(Conf25)})
                      (['tmmx','soil', 'pr']) 

the part (['tmmx','soil', 'pr']) is being taken as a function call; you're trying to use the ee.ImageCollection resulting from annual_max_temp.filterDate(...).map(...) as a function, which it isn't.

Did you perhaps mean to write this?

                      .select(['tmmx','soil', 'pr']) 

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.