0

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.

2 Answers 2

0

After getting the list on the client-side, it was possible to call map() and thus I solved the problem the following way:

var sampleSquaresList = sampleSquares.getInfo() // gets the list on the client side
sampleSquaresList.map(function(f){
    var index_f = sampleSquaresList.indexOf(f)
    Export.image.toDrive({
      image: drone_image_unscaled,
      description: 'test_' + index_f.toString(),
      folder: folderName,
      scale: 0.1,
      region: f
    });
0

Without a full working script, it's hard to know how to advise you, but in general, if you have lots of small regions to extract, it's better to use getDownloadURL or getThumbURL to avoid the overhead of submitting and waiting for tasks to ramp up / ramp down.

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.