公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ee.ImageCollection.toBands
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
将集合转换为包含集合中每张图片的所有波段的单个多波段图片。输出波段的命名方式是在现有波段名称前添加来源影像的 ID(例如,'image1_band1')。注意:频段数量上限为 5,000。
用法 | 返回 |
---|
ImageCollection.toBands() | 图片 |
参数 | 类型 | 详细信息 |
---|
此:collection | ImageCollection | 输入集合。 |
示例
代码编辑器 (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())
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003e\u003ccode\u003etoBands()\u003c/code\u003e transforms an ImageCollection into a single multi-band image, combining all bands from each image within the collection.\u003c/p\u003e\n"],["\u003cp\u003eBand names in the output image are prefixed with the original image ID to identify their source.\u003c/p\u003e\n"],["\u003cp\u003eThe band order in the output image reflects the order of images within the input collection, which can be controlled using \u003ccode\u003esort()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThere is a limit of 5000 bands for the output multi-band image.\u003c/p\u003e\n"]]],["The `toBands()` method converts an ImageCollection into a single multi-band Image. Each band in the resulting image corresponds to a band from an image in the collection. The output band names are prefixed with the source image's ID. The order of bands in the output image matches the order of images in the collection. Users can sort the collection to customize the band order, however the maximum band limit is 5000.\n"],null,["# ee.ImageCollection.toBands\n\nConverts a collection to a single multi-band image containing all of the bands of every image in the collection. Output bands are named by prefixing the existing band names with the image id from which it came (e.g., 'image1_band1'). Note: The maximum number of bands is 5000.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|-----------------------------|---------|\n| ImageCollection.toBands`()` | Image |\n\n| Argument | Type | Details |\n|--------------------|-----------------|-----------------------|\n| this: `collection` | ImageCollection | The input collection. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// A Landsat 8 TOA image collection (2 months of images at a specific point).\nvar col = ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')\n .filterBounds(ee.Geometry.Point(-90.70, 34.71))\n .filterDate('2020-07-01', '2020-09-01')\n .select('B[4-5]'); // Get NIR and SWIR1 bands only.\nprint('Collection', col);\n\n// Convert the image collection to a single multi-band image. Note that image ID\n// ('system:index') is prepended to band names to delineate the source images.\nvar img = col.toBands();\nprint('Collection to bands', img);\n\n// Band order is determined by collection order. Here, the collection is\n// sorted in descending order of the date of observation (reverse of previous).\nvar bandOrder = col.sort('DATE_ACQUIRED', false).toBands();\nprint('Customized band order', bandOrder);\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\n# A Landsat 8 TOA image collection (2 months of images at a specific point).\ncol = (\n ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')\n .filterBounds(ee.Geometry.Point(-90.70, 34.71))\n .filterDate('2020-07-01', '2020-09-01')\n .select('B[4-5]')\n) # Get NIR and SWIR1 bands only.\nprint('Collection:', col.getInfo())\n\n# Convert the image collection to a single multi-band image. Note that image ID\n# ('system:index') is prepended to band names to delineate the source images.\nimg = col.toBands()\nprint('Collection to bands:', img.getInfo())\n\n# Band order is determined by collection order. Here, the collection is\n# sorted in descending order of the date of observation (reverse of previous).\nband_order = col.sort('DATE_ACQUIRED', False).toBands()\nprint('Customized band order:', band_order.getInfo())\n```"]]