ee.ImageCollection.toBands

将集合转换为包含集合中每张图片的所有波段的单个多波段图片。输出波段的命名方式是在现有波段名称前添加来源影像的 ID(例如,'image1_band1')。注意:频段数量上限为 5,000。

用法返回
ImageCollection.toBands()图片
参数类型详细信息
此:collectionImageCollection输入集合。

示例

代码编辑器 (JavaScript)

// A Landsat 8 TOA image collection (2 months 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-07-01', '2020-09-01')
  .select('B[4-5]');  // Get NIR and SWIR1 bands only.
print('Collection', col);

// Convert the image collection to a single multi-band image. Note that image ID
// ('system:index') is prepended to band names to delineate the source images.
var img = col.toBands();
print('Collection to bands', img);

// Band order is determined by collection order. Here, the collection is
// sorted in descending order of the date of observation (reverse of previous).
var bandOrder = col.sort('DATE_ACQUIRED', false).toBands();
print('Customized band order', bandOrder);

Python 设置

如需了解 Python API 和如何使用 geemap 进行交互式开发,请参阅 Python 环境页面。

import ee
import geemap.core as geemap

Colab (Python)

# A Landsat 8 TOA image collection (2 months of images at a specific point).
col = (
    ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')
    .filterBounds(ee.Geometry.Point(-90.70, 34.71))
    .filterDate('2020-07-01', '2020-09-01')
    .select('B[4-5]')
)  # Get NIR and SWIR1 bands only.
print('Collection:', col.getInfo())

# Convert the image collection to a single multi-band image. Note that image ID
# ('system:index') is prepended to band names to delineate the source images.
img = col.toBands()
print('Collection to bands:', img.getInfo())

# Band order is determined by collection order. Here, the collection is
# sorted in descending order of the date of observation (reverse of previous).
band_order = col.sort('DATE_ACQUIRED', False).toBands()
print('Customized band order:', band_order.getInfo())