I want to export NDVI raster data (MOD13A1.006 Terra Vegetation Indices 16-Day Global 500m) from Google Earth Engine for each vegetation growing period from 2000 till 2016. If I filter the year differently (e.g. '2000-09-01', '2001-04-30'), the exported data is the same when uploading into QGIS, which is very unlikely when e.g. looking at a 16 year time frame. What do I need to change within in the code to get the accurate data for each period?

Here is a copy of the code I used for the vegetation growing period of 2015/2016:

Map.addLayer (studyarea, {},'studyarea');

Map.centerObject (studyarea)

var dataset = ee.ImageCollection('MODIS/006/MOD13A1')
                  .filter(ee.Filter.date('2015-09-01', '2016-04-30'));

var ndvi = dataset.select('NDVI'); 
var ndviVis = {
  min: 0.0,
  max: 9000.0,
  palette: [
    'FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718', '74A901',
    '66A000', '529400', '3E8601', '207401', '056201', '004C00', '023B01',
    '012E01', '011D01', '011301' 

Map.addLayer(ndvi, ndviVis, 'NDVI');

var median = ImageCollection.median();

var clip = median.clip(studyarea)

Map.addLayer(clip, ['white', 'black'], 'clipped_NDVI_2016');

Export.image(clip, 'NDVI500m_2015_09_2016_04');
  • 1
    Please edit your question and add code as text, not as an image.
    – TomazicM
    Jun 12, 2021 at 14:57
  • Could you clarify if what you are you trying to obtain is a median NDVI image for each growing period from 2000 to 2016 (e.g., 09-01 from one year to 04-30 of the next year)? Jun 12, 2021 at 20:41
  • Thanks for your answer! Yes, that is exactly what I would like to do.
    – s5s
    Jun 12, 2021 at 21:05

1 Answer 1


Here is a solution to obtain the NDVI median for each growing season. The first part is creating a sequence for all the years that want to be evaluated. Then create a function to do the filtering and calculating the median for each year. Afterwards, this function is mapped to the years list. Then, the results are converted to an image collection and finally, use a for loop to export each image in this image collection.

// Create a sequence of the years that want to be evaluated
var yearsEval = ee.List.sequence({
  start: 2000,
  end: 2016,
  step: 1

// Function to get the NDVI median for each year
var yearNDVI = function(year){
  // Create start and end dates for each entry of the yearsEval list
  var dateStart = ee.Date.fromYMD(ee.Number(year),ee.Number(9),ee.Number(1));
  var dateEnd = ee.Date.fromYMD(ee.Number(year).add(1),ee.Number(4),ee.Number(30));
  // Filter image collection according to dates, study area and select NDVI
  var dataset = ee.ImageCollection('MODIS/006/MOD13A1') 
    .filter(ee.Filter.date(dateStart, dateEnd))

  // Calculate median
  var median = dataset.median();

  // Clip image to study area
  var imageClip = median.clip(studyarea);
  // Add the start year property to each image
  imageClip = imageClip.set('startYear',year);
  // Return image
  return ee.Image(imageClip);

// Map the function to all the entries in the yearEval list
var resul = yearsEval.map(yearNDVI);
// Create an image collection from the list of images generated in the last step
resul = ee.ImageCollection.fromImages(resul);

// Use a loop to export each image in the imagecollection
var i = 0;
  // Create a year variable by summing the starting year (2000) and i
  var year = 2000 + i;
  // Select the image for that year
  var image = resul.filter(ee.Filter.eq('startYear',year));
  // Get the first image, to get an ee.Image object
  image = image.first();
  // Export image using the year as variable
  Export.image(image, 'NDVI500m_start' + year);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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