ee.data.computePixels (Python only)

對圖片資料執行任意計算,藉此計算圖塊。

傳回: 以原始圖片資料形式傳回像素。

用量傳回
ee.data.computePixels(params)物件|值
引數類型詳細資料
params物件物件,內含下列可能值的參數:
expression - 要計算的運算式。
fileFormat:產生的檔案格式。預設值為 png。如需可用格式,請參閱「ImageFileFormat」。此外,還有其他格式可將下載的物件轉換為 Python 資料物件。包括: NUMPY_NDARRAY,可轉換為結構化 NumPy 陣列。
grid - 描述要擷取資料的像素格線的參數。 預設為資料的原生像素格線。
bandIds - 如有,則指定要從中取得像素的特定頻帶組合。
visualizationOptions - 如果存在,則為一組要套用的視覺化選項,用來產生資料的 8 位元 RGB 視覺化結果,而不是傳回原始資料。
workloadTag - 使用者提供的標記,用於追蹤這項運算。

範例

Python 設定

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

import ee
import geemap.core as geemap

Colab (Python)

# Region of interest.
coords = [
    -121.58626826832939,
    38.059141484827485,
]
region = ee.Geometry.Point(coords)

# Sentinel-2 median composite.
image = (ee.ImageCollection('COPERNICUS/S2')
              .filterBounds(region)
              .filterDate('2020-04-01', '2020-09-01')
              .median())

# Make a projection to discover the scale in degrees.
proj = ee.Projection('EPSG:4326').atScale(10).getInfo()

# Get scales out of the transform.
scale_x = proj['transform'][0]
scale_y = -proj['transform'][4]

# Make a request object.
request = {
    'expression': image,
    'fileFormat': 'PNG',
    'bandIds': ['B4', 'B3', 'B2'],
    'grid': {
        'dimensions': {
            'width': 640,
            'height': 640
        },
        'affineTransform': {
            'scaleX': scale_x,
            'shearX': 0,
            'translateX': coords[0],
            'shearY': 0,
            'scaleY': scale_y,
            'translateY': coords[1]
        },
        'crsCode': proj['crs'],
    },
    'visualizationOptions': {'ranges': [{'min': 0, 'max': 3000}]},
}

image_png = ee.data.computePixels(request)
# Do something with the image...