ee.Image.stratifiedSample

Extracts a stratified random sample of points from an image. Extracts the specified number of samples for each distinct value discovered within the 'classBand'. Returns a FeatureCollection of 1 Feature per extracted point, with each feature having 1 property per band in the input image. If there are less than the specified number of samples available for a given class value, then all of the points for that class will be included. Requires that the classBand contain integer values.

UsageReturns
Image.stratifiedSample(numPoints, classBand, region, scale, projection, seed, classValues, classPoints, dropNulls, tileScale, geometries)FeatureCollection
ArgumentTypeDetails
this: imageImageThe image to sample.
numPointsIntegerThe default number of points to sample in each class. Can be overridden for specific classes using the 'classValues' and 'classPoints' properties.
classBandString, default: nullThe name of the band containing the classes to use for stratification. If unspecified, the first band of the input image is used.
regionGeometry, default: nullThe region to sample from. If unspecified, the input image's whole footprint is used.
scaleFloat, default: nullA nominal scale in meters of the projection to sample in. Defaults to the scale of the first band of the input image.
projectionProjection, default: nullThe projection in which to sample. If unspecified, the projection of the input image's first band is used. If specified in addition to scale, rescaled to the specified scale.
seedInteger, default: 0A randomization seed to use for subsampling.
classValuesList, default: nullA list of class values for which to override the numPoints parameter. Must be the same size as classPoints or null.
classPointsList, default: nullA list of the per-class maximum number of pixels to sample for each class in the classValues list. Must be the same size as classValues or null.
dropNullsBoolean, default: trueSkip pixels in which any band is masked.
tileScaleFloat, default: 1A scaling factor used to reduce aggregation tile size; using a larger tileScale (e.g., 2 or 4) may enable computations that run out of memory with the default.
geometriesBoolean, default: falseIf true, the results will include a geometry per sampled pixel. Otherwise, geometries will be omitted (saving memory).