I have multiple images that I am processing and would like to then export their values as a CSV table.
All the following code is available and should be easily reproducible:
var age = ee.Image('users/celsohlsj/public/secondary_vegetation_age_collection71_v5').select('classification_2020');
var amazon_biome = ee.FeatureCollection('projects/ee-ana-zonia/assets/amazon_biome_border');
var ecoregions = ee.FeatureCollection("RESOLVE/ECOREGIONS/2017");
// Clip to Amazon biome
var age = age.clip(amazon_biome).updateMask(age.gt(0));
var ecoregions = ecoregions.filterBounds(amazon_biome.geometry());
var ecoregions_list = ecoregions.toList(ecoregions.size());
var i = 2;
var ecoreg = ee.Feature(ecoregions_list.get(i));
var img_clipped = age.clip(ecoreg);
// extract pixels into a FeatureCollection
var points = img_clipped.sample({
scale: 30,
projection: img_clipped.projection()
});
// Use image.reduceRegions to convert to FeatureCollection for the selected ecoregion
var featcol = img_clipped.reduceRegions({
collection: points,
reducer: ee.Reducer.first(),
scale: 30});
// Export all features in a FeatureCollection as one file
Export.table.toDrive({
collection: featcol,
fileNamePrefix: ee.String(ecoreg.get('ECO_ID')).cat('_age'),
fileFormat: 'CSV'
});
Ideally, I'd have one CSV file for each ecoregion.
is not working out as the value is too large:
myExportTableTask ID: QKMSEOB4DVUL3VPZH5UD3SNK Phase: Failed Runtime: 49s (started 2023-11-26 20:22:09 -0500) Attempted 1 time Error: Image.sample: Computed value is too large. (Error code: 3)
I saw this solution GEE export too large data but I don't understand how mosaic could help here, mainly as I am using Images, not ImageCollections.
I tried using an ImageCollection, as it just made sense to avoid repetitive code (I am doing the same for multiple images, not just "age"), but I am too much of a beginner and got really confused so just went with Images for now.
Also, these images don't seem to be so large, as right now I am exporting them as .tif and img_clipped was 66mb.
Any ideas on how I can easily export these large images as CSV?