Skip to main content
1 of 2

How to export multiple images with different geometries

I have a large drone photo from which I want to generate multiple samples based on selected points (red pins on the image).

The function that selects the geometry around the pin is the following:

var expandToSquare = function(point) {
  return ee.Geometry.Point(point).buffer(10).bounds()
}

The list of geometries is generated as follows:

var samplePoints = samples.coordinates(); // samples are the pins placed by the user
var sampleSquares = samplePoints.map(expandToSquare);

enter image description here

In the case of creating an example for exporting a neighborhood of a specific point, everything works fine:

Export.image.toDrive({
    image: drone_image_unscaled,
    description: 'test',
    scale: 0.1,
    region: sampleSquares.get(2)
  });

In order to generate the export for every pin, I tried to wrap the above code in for loop, but it didn't work:

var samplesCount = sampleSquares.size();
for(var i = 0; i < samplesCount; i++){
  Export.image.toDrive({
    image: drone_image_unscaled,
    description: 'test_'+i.toString(),
    scale: 0.1,
    region: sampleSquares.get(i)
  });

I tried to use geetols-code-editor batch helper but couldn't make it work.

I also tried to adapt some of the solutions I found here, but none have worked so far. I would be thankful for a suggestion.