公告:凡是在
2025 年 4 月 15 日前註冊使用 Earth Engine 的非商業專案,都必須
驗證非商業用途資格,才能繼續存取 Earth Engine。
ee.Image.where
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
有條件地替換值。
針對「input」每個波段中的每個像素,如果「test」中對應的像素不為零,則輸出「value」中對應的像素,否則輸出輸入像素。
如果特定像素的測試或值遭到遮蓋,系統會使用輸入值。如果輸入內容已遮蓋,系統不會採取任何動作。
輸出頻帶的名稱與輸入頻帶相同。每個頻帶的輸出類型是輸入和值類型中較大的類型。輸出圖片會保留輸入圖片的中繼資料和足跡。
用量 | 傳回 |
---|
Image.where(test, value) | 圖片 |
引數 | 類型 | 詳細資料 |
---|
這個:input | 圖片 | 輸入圖片。 |
test | 圖片 | 測試圖片。這張圖片的像素會決定要傳回哪些輸入像素。如果是單一波段,則會用於輸入圖片中的所有波段。這可能不是陣列圖片。 |
value | 圖片 | 測試值不為零時要使用的輸出值。如果是單一波段,則會用於輸入圖片中的所有波段。 |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間:2025-07-26 (世界標準時間)。"],[[["\u003cp\u003eReplaces input image pixel values with values from a secondary image based on a test image's pixel values.\u003c/p\u003e\n"],["\u003cp\u003eIf the test image pixel is non-zero, the corresponding pixel from the value image is used; otherwise, the original input pixel is retained.\u003c/p\u003e\n"],["\u003cp\u003eInput image metadata and footprint are preserved in the output image.\u003c/p\u003e\n"],["\u003cp\u003eOutput image band types are determined by the larger type between the input and value images.\u003c/p\u003e\n"],["\u003cp\u003eMasked pixels in either test or value images result in the original input pixel being used in the output.\u003c/p\u003e\n"]]],[],null,["# ee.Image.where\n\nPerforms conditional replacement of values.\n\n\u003cbr /\u003e\n\nFor each pixel in each band of 'input', if the corresponding pixel in 'test' is nonzero, output the corresponding pixel in value, otherwise output the input pixel.\n\nIf at a given pixel, either test or value is masked, the input value is used. If the input is masked, nothing is done.\n\nThe output bands have the same names as the input bands. The output type of each band is the larger of the input and value types. The output image retains the metadata and footprint of the input image.\n\n| Usage | Returns |\n|----------------------------|---------|\n| Image.where`(test, value)` | Image |\n\n| Argument | Type | Details |\n|---------------|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| this: `input` | Image | The input image. |\n| `test` | Image | The test image. The pixels of this image determines which of the input pixels is returned. If this is a single band, it is used for all bands in the input image. This may not be an array image. |\n| `value` | Image | The output value to use where test is not zero. If this is a single band, it is used for all bands in the input image. |"]]