0

Is it possible to export a collection of images directly to the asset by renaming the images? I have tried to use fito's geetbox but I can't do it.

My code:

for (var i = 0; i < 12; i++) {
    var img = ee.Image(listOfImage.get(i));
    var id = img.id().getInfo() || 'image_'+i.toString();
    var region = opt.region || img.geometry().bounds().getInfo()["system:Index"];
    var assetId = SCI_ENERO
    
    Export.image.toAsset({
      image: img,
      description: id,
      assetId: assetId,
      region: region,
      scale: opt.scale,
      maxPixels: opt.maxPixels})
  }

1 Answer 1

6

I don't know that guy, but I think you have taken his code and tried to implemented directly, but you didn't adapt it to your needs.

You have two ways

To adapt it:

var p = ee.Geometry.Point([-72, -42])
var col = ee.ImageCollection('COPERNICUS/S2')
            .filterBounds(p)
            .limit(5)

var size = col.size().getInfo()
var listOfImage = col.toList(size)

for (var i = 0; i < size; i++) {
    var img = ee.Image(listOfImage.get(i));
    var id = img.id().getInfo() || 'image_'+i.toString();
    var region = p.buffer(1000)
    var assetId = 'TEST'
    
    Export.image.toAsset({
      image: img,
      description: id,
      assetId: assetId,
      region: region,
      scale: 10,
      maxPixels: 1e13
    })
  }

https://code.earthengine.google.com/5d3a58b8d035d9bb29014dcf91a2a162

Or just use his (awesome) package:

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

var p = ee.Geometry.Point([-72, -42])
var col = ee.ImageCollection('COPERNICUS/S2')
            .filterBounds(p)
            .limit(5)

var asset = 'TEST'
var options = {
  name: 'S2_{system_date}',
  scale: 10,
  maxPixels: 1e13,
  region: p.buffer(1000)
}

batch.Download.ImageCollection.toAsset(col, asset, options)

https://code.earthengine.google.com/387777af874beed8a63bd6b4cff8bfa8

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.