I have an image ('biome') and a feature collection ('grid'). I want to sample points on the image, precisely 10 points per feature(a grid cell). Also, I want to drop points that intersect the masked pixel (oceans) of an image.
When I try with the ee.Image.sample
function, I can drop points in the ocean but I can't specify the number of points per grid cell.
When I try with ee.FeatureCollection.randomPoints
function, I can specify the number of points per grid cell but I can't drop the points in the ocean.
Does anyone have any ideas?
Link to the script : https://code.earthengine.google.com/91366ac39038271ed66115eb9bb87e7f
var biome = ee.Image("OpenLandMap/PNV/PNV_BIOME-TYPE_BIOME00K_C/v01");
var grid = american.coveringGrid('EPSG:4326', 500000);
Map.addLayer(biome, null, "biome");
Map.addLayer(grid, null, "grid");
// sample function
var points = biome.sample({
region : grid.geometry(),
scale : 30,
numPixels : 10
});
print(points);
Map.addLayer(points, null, 'points');
//randomPoints function
var points1 = grid.map(function(feature){
return ee.FeatureCollection.randomPoints({
region:feature.geometry(), points:10})
});
var points1 = points1.flatten();
print(points1);
Map.addLayer(points1);
// How to sample 10 points randomly per grid cell while dropping all sampled points that intersect masked pixels of biome image?