I need to create a monthly NDVI time series from GIMMS in GEE (i.e. from January 1981 to December 2013) from the sum of fortnight values (or mean). I've been trying to create a function to do so, but can't figure it out.

I try this code, but generates annual sums, not monthly sums...

var monthly = 

closed as off-topic by PolyGeo Jul 4 at 7:47

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "When seeking help to debug/write/improve code always provide the desired behavior, a specific problem/error and the shortest code (as formatted text, not pictures) needed to reproduce it in the question body. Providing a clear problem statement and a code attempt helps others to help you." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    The code appears to be incomplete. How is the variable "mageCollection" defined? – Tyler Erickson Nov 17 '17 at 20:54

I had the same issue before... I tried to do the same thing with MODIS, so, I asked at Stack Overflow.

Based on an excellent answer from Rodrigo E. Principe, you should apply two map() functions to filter by month and year. Inside one created function, you can add sum() to sums for each month by year:

var imageCollection = ee.ImageCollection("NASA/GIMMS/3GV0");

var years = ee.List.sequence(1981, 2013);
var months = ee.List.sequence(1, 12);

var map_m = function(i) {
  i = ee.Number(i);
  var filtered_col = years.map(function(j) {
    var filtered = imageCollection
        .filter(ee.Filter.calendarRange(i, i, 'month'))
        .filter(ee.Filter.calendarRange(j, j, 'year'))
    return filtered;
  return filtered_col;

var img_col = ee.ImageCollection(months.map(map_m).flatten());


var checkImage = ee.Image(img_col.filter(ee.Filter.eq('system:index', '10')).first());
Map.addLayer(checkImage, {min:-1,max:1}, 'test');

Link to reproducible example: https://code.earthengine.google.com/cb8422e2d888fd3cd85f57db5920d917

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