2

I'm want to export some pixels with feature to my google drive:

var exportData = function(table, prefix, year) {
  Export.table.toDrive({
    collection: table,
    description: prefix,
    folder: year,  
    fileNamePrefix: prefix
  });
};

var first = ee.ImageCollection('COPERNICUS/S2_SR')
                .filterBounds(ee.Geometry.Point(-70.48, 43.3631))
                .filterDate('2019-01-01', '2019-12-31')
                .sort('CLOUDY_PIXEL_PERCENTAGE')
                .first();

var samples = first.sample({
  numPixels: 1000,
  geometries: true,

});

exportData(samples, 'county', '2019');

But if, just if, the samples is very big, the download will get an error like this:

ID: ZHJAJBZ3NI6Y2CMGVMDDTJPP
Phase: Failed
Runtime: 1m (started 2023-05-08 08:51:57 -0500)
Attempted 1 time
Error: Image.reduceRegions: Computed value is too large. (Error code: 3)

So my question is that, is there any method to automatically split the too big value to download? for example, like this:

if(samples is big):
  sample_1, sample_2 = samples.split()
  exportData(sample_1, 'county_1', '2019')
  exportData(sample_2, 'county_2', '2019')

if not, could you tell me what's the most elegant method to solve this problem?

1 Answer 1

2

You can do something like this:

var clipped = first.mosaic().clip(area)

For the area you can use a polygon inside the code-editor.

For a example, how to use it watch here.

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.