ee.ImageCollection.toList

以清單形式傳回集合的元素。

用量傳回
ImageCollection.toList(count, offset)清單
引數類型詳細資料
這個:collectionFeatureCollection要擷取的輸入集合。
count整數要擷取的元素數量上限。
offset整數,預設值為 0要從開頭捨棄的元素數量。如果已設定,系統會擷取 (位移 + 數量) 個元素,並捨棄前幾個位移元素。

範例

程式碼編輯器 (JavaScript)

// Note: ee.ImageCollection.toList may take a lot of time and memory to run,
// since it must generate all of the results in order to gather them into a
// list. Large collections and/or complex computations can produce memory
// limitation errors.

// A Landsat 8 TOA image collection (1 year of images at a specific point).
var col = ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')
  .filterBounds(ee.Geometry.Point(-90.70, 34.71))
  .filterDate('2020-01-01', '2021-01-01');
print('Image collection', col);

// Get the first 3 images as a list of images.
var imgListFirst3 = col.toList(3);
print('First 3 images', imgListFirst3);

// Get the second 3 images as a list of images (use the offset parameter).
var imgListSecond3 = col.toList(3, 3);
print('Second 3 images', imgListSecond3);

Python 設定

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

import ee
import geemap.core as geemap

Colab (Python)

# Note: ee.ImageCollection.toList may take a lot of time and memory to run,
# since it must generate all of the results in order to gather them into a
# list. Large collections and/or complex computations can produce memory
# limitation errors.

# A Landsat 8 TOA image collection (1 year of images at a specific point).
col = ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA').filterBounds(
    ee.Geometry.Point(-90.70, 34.71)).filterDate('2020-01-01', '2021-01-01')
print('Image collection:', col.getInfo())

# Get the first 3 images as a list of images.
img_list_first3 = col.toList(3)
print('First 3 images:', img_list_first3.getInfo())

# Get the second 3 images as a list of images (use the offset parameter).
img_list_second3 = col.toList(3, 3)
print('Second 3 images:', img_list_second3.getInfo())