I'm trying to export to the drive all the images within a MODIS satellite collection. I came across this question, which is given exactly the answer I need:

link: Exporting entire ImageCollection in Google Earth Engine using geetools for JavaScript or Python for Windows?


var batch = require('users/fitoprincipe/geetools:batch')

var collection = ee.ImageCollection('MODIS/006/MOD13A1')  
                .filterDate(startDate, endDate)
var count = collection.size()

var all_tiles = collection.map(function(image) { return image.multiply(0.0001).clip(haryana).mask(agrimask_2001).reproject('EPSG:4326', null, 500); }); 

var collectionList = all_tiles.toList(all_tiles.size());
var n = collectionList.size().getInfo();

for (var i = 0; i < n; i++) {
      var listOfImages = all_tiles.toList(all_tiles.size());
      var Tile = listOfImages.get(i);
      var allRasters = ee.ImageCollection.fromImages([Tile]);
      batch.Download.ImageCollection.toDrive(allRasters, "MODIS Test Download", 
      {name: 'MODIS_{system:index}',
      scale: 500,
      region: yourAreaOfInterest

However, the compiler gives me an error: Line 13: agrimask_2001 is not defined

What is agrimask_2001? I can't find any information online.

  • Perhaps you should ask the person who posted that answer how HIS script is working
    – HDunn
    Commented Aug 26, 2021 at 8:28

1 Answer 1


agrimask_2001 must have been loaded by the user beforehand, so noone (but him/her) can know what exactly it is as it's not included in the code (probably some mask to include croplands only). However, if you don't need that mask you can just delete .mask(agrimask_2001) and run your code, this should work.

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.