公告:凡是在
2025 年 4 月 15 日前註冊使用 Earth Engine 的非商業專案,都必須
驗證非商業用途資格,才能繼續存取 Earth Engine。
ee.Image.stratifiedSample
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
從圖片中擷取分層隨機點樣本。針對在「classBand」中發現的每個相異值,擷取指定數量的樣本。傳回每個擷取點的 1 個特徵的 FeatureCollection,每個特徵在輸入圖片中每個波段都有 1 個屬性。如果特定類別值可用的樣本數少於指定數量,系統就會納入該類別的所有點。要求 classBand 包含整數值。
用量 | 傳回 |
---|
Image.stratifiedSample(numPoints, classBand, region, scale, projection, seed, classValues, classPoints, dropNulls, tileScale, geometries) | FeatureCollection |
引數 | 類型 | 詳細資料 |
---|
這個:image | 圖片 | 要取樣的圖片。 |
numPoints | 整數 | 每個類別中要取樣的預設點數。你可以使用「classValues」和「classPoints」屬性,覆寫特定類別的這項屬性。 |
classBand | 字串,預設值為空值 | 包含用於分層的類別的樂團名稱。如未指定,系統會使用輸入圖片的第一個波段。 |
region | 幾何圖形,預設值:null | 要取樣的區域。如未指定,系統會使用輸入圖片的完整足跡。 |
scale | 浮點值,預設值為空值 | 投影的公尺名義比例,用於取樣。預設為輸入圖像第一個波段的比例。 |
projection | 投影,預設值:null | 要取樣的投影。如未指定,系統會使用輸入圖片第一個頻帶的投影。如果除了比例外還指定了其他值,系統會重新調整為指定比例。 |
seed | 整數,預設值為 0 | 用於子取樣的隨機化種子。 |
classValues | 清單,預設值為空值 | 要覆寫 numPoints 參數的類別值清單。必須與 classPoints 大小相同,或為空值。 |
classPoints | 清單,預設值為空值 | 每個類別的像素取樣數量上限清單,對應 classValues 清單中的每個類別。大小必須與 classValues 相同,或為空值。 |
dropNulls | 布林值,預設值為 true | 略過任何頻帶遭到遮蓋的像素。 |
tileScale | 浮點值,預設值為 1 | 用於縮小聚合圖塊大小的縮放比例因數;使用較大的 tileScale (例如 2 或 4) 可能會啟用運算,導致記憶體不足。 |
geometries | 布林值,預設值為 false | 如果為 true,結果會包含每個取樣像素的幾何圖形。否則系統會省略幾何圖形 (節省記憶體)。 |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間: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). |"]]