公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ee.Image.stratifiedSample
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
从图片中提取分层随机点样本。针对在“classBand”中发现的每个不同的值提取指定数量的样本。返回一个 FeatureCollection,其中包含每个提取的点对应的 1 个 Feature,每个 Feature 具有输入图片中每个波段对应的 1 个属性。如果指定类别值可用的样本数量少于指定数量,则会纳入该类别的所有点。要求 classBand 包含整数值。
用法 | 返回 |
---|
Image.stratifiedSample(numPoints, classBand, region, scale, projection, seed, classValues, classPoints, dropNulls, tileScale, geometries) | FeatureCollection |
参数 | 类型 | 详细信息 |
---|
此:image | 图片 | 要抽样的图片。 |
numPoints | 整数 | 每个类别中要抽样的默认点数。可以使用“classValues”和“classPoints”属性针对特定类别进行覆盖。 |
classBand | 字符串,默认值:null | 包含用于分层的类别的波段的名称。如果未指定,则使用输入图像的第一个波段。 |
region | 几何图形,默认值:null | 要从中抽样的区域。如果未指定,则使用输入图片的整个覆盖区。 |
scale | 浮点数,默认值:null | 要采样的投影的标称比例(以米为单位)。默认为输入图像第一个波段的比例。 |
projection | 投影,默认值:null | 要进行抽样的投影。如果未指定,则使用输入映像第一个波段的投影。如果除了缩放比例之外还指定了此参数,则会重新缩放到指定的缩放比例。 |
seed | 整数,默认值:0 | 用于子采样的随机化种子。 |
classValues | 列表,默认值:null | 要替换 numPoints 参数的类值列表。必须与 classPoints 的大小相同或为 null。 |
classPoints | 列表,默认值:null | 一个列表,其中包含 classValues 列表中每个类别的每个类别的像素抽样数量上限。必须与 classValues 的大小相同或为 null。 |
dropNulls | 布尔值,默认值:true | 跳过任何波段被遮盖的像素。 |
tileScale | 浮点数,默认值:1 | 用于减小聚合图块大小的缩放比例;使用较大的 tileScale(例如,2 或 4)可能会启用内存不足的计算(使用默认值)。 |
geometries | 布尔值,默认值:false | 如果为 true,结果将包含每个抽样像素的几何图形。否则,系统会省略几何图形(节省内存)。 |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eExtracts a stratified random sample of points from an image based on distinct class values within a specified band.\u003c/p\u003e\n"],["\u003cp\u003eReturns a FeatureCollection containing one feature per sampled point, each with properties corresponding to the image bands.\u003c/p\u003e\n"],["\u003cp\u003eAllows customization of the number of samples per class, sampling region, scale, projection, and randomization.\u003c/p\u003e\n"],["\u003cp\u003eHandles cases with insufficient samples for a class by including all available points for that class.\u003c/p\u003e\n"],["\u003cp\u003eRequires the class band to contain integer values for proper stratification.\u003c/p\u003e\n"]]],[],null,["# ee.Image.stratifiedSample\n\nExtracts 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.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|\n| Image.stratifiedSample`(numPoints, `*classBand* `, `*region* `, `*scale* `, `*projection* `, `*seed* `, `*classValues* `, `*classPoints* `, `*dropNulls* `, `*tileScale* `, `*geometries*`)` | FeatureCollection |\n\n| Argument | Type | Details |\n|---------------|---------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| this: `image` | Image | The image to sample. |\n| `numPoints` | Integer | The default number of points to sample in each class. Can be overridden for specific classes using the 'classValues' and 'classPoints' properties. |\n| `classBand` | String, default: null | The name of the band containing the classes to use for stratification. If unspecified, the first band of the input image is used. |\n| `region` | Geometry, default: null | The region to sample from. If unspecified, the input image's whole footprint is used. |\n| `scale` | Float, default: null | A nominal scale in meters of the projection to sample in. Defaults to the scale of the first band of the input image. |\n| `projection` | Projection, default: null | The 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. |\n| `seed` | Integer, default: 0 | A randomization seed to use for subsampling. |\n| `classValues` | List, default: null | A list of class values for which to override the numPoints parameter. Must be the same size as classPoints or null. |\n| `classPoints` | List, default: null | A 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. |\n| `dropNulls` | Boolean, default: true | Skip pixels in which any band is masked. |\n| `tileScale` | Float, default: 1 | A 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. |\n| `geometries` | Boolean, default: false | If true, the results will include a geometry per sampled pixel. Otherwise, geometries will be omitted (saving memory). |"]]