Link for the code: https://code.earthengine.google.com/89616ca3147334915eca9f3957bb778f
I am using GEE in order to access image, generate random points on top of it and then sample it using the random points.
I have found out unexpected behavior : I generate 200 random points, and then when I sample the region, I get back only 192 points.
This happens for different numbers of sample points:
(500 random points ->472 sampled
100 random points -> 95 sampled
1000 random points -> 946 sampled
etc...)
var smap=ee.ImageCollection('NASA_USDA/HSL/SMAP10KM_soil_moisture').filterBounds(geometry).filterDate('2020-01-01', '2021-01-01').median().clip(geometry);
var randomPoints = ee.FeatureCollection.randomPoints(
{region:geometry, points: 1000});
var fcPointSamp = smap.sampleRegions({
collection: randomPoints,
scale: 10000
});
Map.addLayer(smap,{},'SMAP');
Map.addLayer(randomPoints,{},'random_points')
Map.centerObject(geometry,8)
print('Number of points', randomPoints.size());
print('Number of sampled points', fcPointSamp.size());
Why does this happen? Is there any way I can control the number of points that are being sampled?
Link for the code: https://code.earthengine.google.com/89616ca3147334915eca9f3957bb778f
EDIT:
based on Daniel's answer: workaround for geemap:
dummy_band=img.addBands(ee.Image(-9999).rename('temp')).clip(fc)
img_replaced_masked = img.unmask(dummy_band.select('temp'))
###replace the masked values in img with the -9999 values
img_mask_masked_values = img.unmask(dummy_band.select('temp'))
then, when I used sampleRegions, the no value pixels got value of "-9999"