According to the documentation of GEE,
- ee.Image.sample() samples the pixels of an image and returns them as a FeatureCollection, in which each feature has 1 property per band in the input image. You can provide a region parameter, which defines the region to sample from, or a factor parameter, which subsamples the image, or a numPixels parameter, which approximates the number of pixels to be sampled. I figure that either all pixels from the region are becoming features, or a randomized subset of pixels. Is that correct?
- ee.Image.SampleRegions() samples the pixels of an image in one or more region and puts them into a FeatureCollection with 1 property per band of the input image. It requires a FeatureCollection as input, which defines the regions to sample over. Geometries will be snapped to pixel centers, thus I understand that there will be one sample per feature in the FeatureCollection, even if the FeatureCollection contains many extended polygons. Is that correct?
- ee.Image.stratifiedSample() extracts stratified random sample points from an image and returns a FeatureCollection of 1 feature per extracted point with each feature having 1 property per band of the input image. It requires a numPoints parameter that defines how many points to sample. Also you can provide a classBand parameter, which tells you the classes to be used for stratification, and a region parameter, which tells you the region to sample from. Thus, other than for the other two sampling operations, you don't need a FeatureCollection as input, but rather a raster band that contains information about the classes. Is that correct?
I am just wondering: When should which of these strategies be used? ee.Image.sample() seems most straight-forward. But can it be used if you have a FeatureCollection of training samples, e.g. containing polygon labels? ee.Image.SampleRegions() seems to be able to do just that, but shrinks all geometries to the centers, if I am not mistaken. And ee.Image.stratifiedSample() will need a raster image containing your classes. Is this possible for sparse label images, i.e. classBands that do not contain a class for every pixel?
I am really confused a little and would be happy to see a set of comparable examples to gain a better understanding...