I'm trying to export all the images in an ImageCollection to Google Drive and by default name the output image with the date using format() function. However, when I try to name a export task by a date, the name in tasks is something like:

ee.String({ "type": "Invocation", "arguments": { "date": { "type": "Invocation", "arguments": { "value": { "type": "Invocation", "arguments": { "object": { "type": "ArgumentRef", "value": "_MAPPING_VAR_0_0" }, "property": "system:time_start" }, "functionName": "Element.get" } }, "functionName": "Date" }, "format": "YYYY-MM-DD" }, "functionName": "Date.format" })

Note the date values are gone and only some of the images are exported. Here's the link to the code

All I need is only a formatted string from a date object.

Is there a simpler way to export an image collection?

  • Export is a client side function, while map is a server side funtion. What you want to achieve will only work if you create a client side loop (for.. in...).
    – Kersten
    Commented Oct 29, 2018 at 9:18
  • Thanks for the tip. For loop do work in this case. GEE strongly recommend not to use the for loop, so maybe I'm mistaken. Commented Oct 29, 2018 at 14:26
  • Avoiding loops is generally a good tactic to avoid inefficient operations. However, that mostly applies to stuff you want to calculate within GEE. The better question might be - why are you exporting Sentinel-2 Vegetation Index images, instead of performing your calculations completely within GEE and only export the final result?
    – Kersten
    Commented Oct 29, 2018 at 17:15
  • I'm new to gee and trying to caculate a spatio-temopral version of Moran's I. But I don't know how to implement it in gee. Sunsetting images to a small region and test that index in Matlab is way faster. Commented Oct 30, 2018 at 1:45

1 Answer 1


As @Kersten commented, you should use a client side loop

var size = S2VI.size().getInfo()
var S2VI_list = S2VI.toList(size)

for (var n=0; n<size; n++) {
  var image = ee.Image(S2VI_list.get(n))
  var date = ee.Date(image.get('system:time_start')).format('YYYY-MM-DD');
  date = date.getInfo();
    image: image,
    description: date,
    fileNamePrefix: date, // this is the name actually
    folder: 'EE Outputs',
    scale: 20,
    region: XiangJiang,
    maxPixels: 130000000000,

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.