ee.ImageCollection.toList

以列表形式返回集合的元素。

用法返回
ImageCollection.toList(count, offset)列表
参数类型详细信息
此:collectionFeatureCollection要提取的输入集合。
count整数要提取的最大元素数量。
offset整数,默认值:0从开头开始要舍弃的元素数量。如果设置了此参数,系统将提取 (offset + count) 个元素,并舍弃前 offset 个元素。

示例

代码编辑器 (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 API 和如何使用 geemap 进行交互式开发,请参阅 Python 环境页面。

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())