圖片縮小

如要減少 Image,請使用 image.reduce()。縮減圖片的運作方式與 imageCollection.reduce() 類似,但圖片的頻帶會輸入至縮減器,而非集合中的圖片。輸出結果也是一張圖片,其頻帶數量等於縮減器輸出數量。範例如下:

程式碼編輯器 (JavaScript)

// Load an image and select some bands of interest.
var image = ee.Image('LANDSAT/LC08/C02/T1/LC08_044034_20140318')
    .select(['B4', 'B3', 'B2']);

// Reduce the image to get a one-band maximum value image.
var maxValue = image.reduce(ee.Reducer.max());

// Display the result.
Map.centerObject(image, 10);
Map.addLayer(maxValue, {max: 13000}, 'Maximum value image');

Python 設定

請參閱「 Python 環境」頁面,瞭解 Python API 和如何使用 geemap 進行互動式開發。

import ee
import geemap.core as geemap

Colab (Python)

# Load an image and select some bands of interest.
image = ee.Image('LANDSAT/LC08/C02/T1/LC08_044034_20140318').select(
    ['B4', 'B3', 'B2']
)

# Reduce the image to get a one-band maximum value image.
max_value = image.reduce(ee.Reducer.max())

# Display the result.
m = geemap.Map()
m.center_object(image, 10)
m.add_layer(max_value, {'max': 13000}, 'Maximum value image')
m