2

I want to clip all the images in a collection separately and export them. I am new to scripting.

//Map.addLayer(table, {color: 'FF0000'} , 'geometry');

var NDVICollection=ee.ImageCollection('MODIS/006/MOD13Q1')
                         .filterDate('2000-01-01','2000-12-31')
                         .filterBounds(table).select('NDVI');

var list = NDVICollection.toList(3);
    for (var i=1;i<4;i++){
         var nam=ee.String('NDVI_img')
                    .cat(ee.String(ee.Number(i)))
                    .getInfo();
var NDVIClipped = NDVICollection.clip(table);

var reprojected = NDVIClipped
    .unitScale(-2000, 10000)
    .reproject('EPSG:4326', null, 500);
//Map.addLayer(reprojected, {min: 0.0, max: 1}, 'Reprojected');
     //print(nam);
     Export.image.toDrive({ 
           image: reprojected,
           description:nam,
           scale: 250,
           maxPixels:1e13
     });
}

I'm getting the error message:

NDVICollection.clip() is not a function.

2
  • Do you get an error message when you run your code or what?
    – BERA
    Jun 13, 2018 at 6:19
  • yes, its saying NDVICollection.clip() is not a function. Jun 13, 2018 at 6:42

1 Answer 1

7

You are trying to use an ee.Image function in an ee.ImageCollection object. You can map using .clip() trough images inside this collection as:

// create function to crop with table boundaries
var table_bounds = function(image) {
  // Crop by table extension
  return image.clip(table);
};

var NDVIClipped = NDVICollection.map(table_bounds);
1
  • 1
    That was really helpful, thanks!
    – Waleed93
    Jul 2, 2020 at 8:09

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.