79519441

Date: 2025-03-19 07:41:53
Score: 2
Natty:
Report link

Thank you @PierrickRambaud!

With .map it was no problem in the end:


// Sample 50 random points from this tile geometry
  var randomPoints = ee.FeatureCollection.randomPoints({
    region: geometry,
    points: 50,  // Number of random points per tile
    seed: 42,  // Seed for reproducibility
    maxError: 1  // Tolerance for random point generation
  });

  // Sample image at the random points
  var sampledData = myImage.sampleRegions({
    collection: randomPoints,
    scale: 10000,  // Sampling scale (depends on the pixel size)
    geometries: true
  });

  // Return the sample with the tile ID
  return sampledData.map(function(feature) {
    return feature.set('tile_id', tileId);  // Add tile ID to each sampled point
  });
};

// Apply the sampling to each tile in the grid and combine the results
var sampledPoints = gridFc.map(sampleFromTile).flatten();

This creates a combined feature collection with all the combined samples.

Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @PierrickRambaud
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Anton