公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ee.ImageCollection.select
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
从集合中的每张图片中选择波段。
返回包含所选波段的影像集合。
用法 | 返回 |
---|
ImageCollection.select(selectors, names) | ImageCollection |
参数 | 类型 | 详细信息 |
---|
此:imagecollection | ImageCollection | ImageCollection 实例。 |
selectors | List<Object> | 一个名称、正则表达式或数字索引列表,用于指定要选择的频段。 |
names | List<String>,可选 | 输出波段的新名称列表。必须与所选频段的数量一致。 |
示例
代码编辑器 (JavaScript)
// A Sentinel-2 surface reflectance image collection.
var col = ee.ImageCollection('COPERNICUS/S2_SR')
.filterBounds(ee.Geometry.Point(-122.152, 37.336))
.filterDate('2021-01-01', '2021-02-01');
print('All band names', col.first().bandNames());
print('Select a band by name',
col.select('B11').first().bandNames());
print('Select a band by index',
col.select(10).first().bandNames());
print('Select bands using a list',
col.select(['B11', 'B8', 'B3']).first().bandNames());
print('Select bands by an argument series',
col.select('B11', 'B8', 'B3').first().bandNames());
print('Mixing string and integer selectors is valid',
col.select(10, 'B8', 2).first().bandNames());
print('Rename selected bands using two corresponding lists',
col.select(['B11', 'B8', 'B3'], ['SWIR1', 'NIR', 'Green'])
.first().bandNames());
// Use regular expressions to select bands.
print('Match "QA" followed by any two characters',
col.select('QA..').first().bandNames());
print('Match "B" followed by any character, any number of times',
col.select('B.*').first().bandNames());
print('Match "B" followed by any character, and any optional third character',
col.select('B..?').first().bandNames());
print('Match "B" followed by a character in the range 6-8',
col.select('B[6-8]').first().bandNames());
print('Match "B" followed by a character in the range 1-9 and then 1-2',
col.select('B[1-9][1-2]').first().bandNames());
print('Match "B" or "QA" each followed by any character, any number of times.',
col.select('B.*|QA.*').first().bandNames());
Python 设置
如需了解 Python API 和如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
# A Sentinel-2 surface reflectance image collection.
col = ee.ImageCollection('COPERNICUS/S2_SR').filterBounds(
ee.Geometry.Point(-122.152, 37.336)
).filterDate('2021-01-01', '2021-02-01')
print('All band names', col.first().bandNames().getInfo())
print('Select a band by name:',
col.select('B11').first().bandNames().getInfo())
print('Select a band by index:',
col.select(10).first().bandNames().getInfo())
print('Select bands using a list:',
col.select(['B11', 'B8', 'B3']).first().bandNames().getInfo())
print('Select bands by an argument series:',
col.select('B11', 'B8', 'B3').first().bandNames().getInfo())
print('Mixing string and integer selectors is valid:',
col.select(10, 'B8', 2).first().bandNames().getInfo())
print('Rename selected bands using two corresponding lists:',
col.select(['B11', 'B8', 'B3'], ['SWIR1', 'NIR', 'Green'])
.first().bandNames().getInfo())
# Use regular expressions to select bands.
print('Match "QA" followed by any two characters:',
col.select('QA..').first().bandNames().getInfo())
print('Match "B" followed by any character, any number of times:',
col.select('B.*').first().bandNames().getInfo())
print('Match "B" followed by any character, and any optional third character:',
col.select('B..?').first().bandNames().getInfo())
print('Match "B" followed by a character in the range 6-8:',
col.select('B[6-8]').first().bandNames().getInfo())
print('Match "B" followed by a character in the range 1-9 and then 1-2:',
col.select('B[1-9][1-2]').first().bandNames().getInfo())
print('Match "B" or "QA" each followed by any character, any number of times:',
col.select('B.*|QA.*').first().bandNames().getInfo())
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003eThe \u003ccode\u003eselect()\u003c/code\u003e method returns an ImageCollection with specified bands selected from each image within the collection.\u003c/p\u003e\n"],["\u003cp\u003eBand selection can be achieved using band names, numeric indices, or regular expressions.\u003c/p\u003e\n"],["\u003cp\u003eSelected bands can be renamed by providing a corresponding list of new names.\u003c/p\u003e\n"],["\u003cp\u003eThe method accepts a flexible combination of selectors, including strings, integers, and lists.\u003c/p\u003e\n"],["\u003cp\u003eRegular expressions enable versatile pattern matching for selecting multiple bands simultaneously.\u003c/p\u003e\n"]]],["The `select` method extracts specific bands from an ImageCollection, returning a new ImageCollection with those bands. Band selection can be done by name, index, or a list of these. New band names can be assigned using an optional list, which must match the number of selected bands. Regular expressions can also be used to select bands based on pattern matching. The code examples demonstrate these selection techniques for both JavaScript and Python.\n"],null,["# ee.ImageCollection.select\n\n\u003cbr /\u003e\n\nSelect bands from each image in a collection.\n\n\u003cbr /\u003e\n\nReturns the image collection with selected bands.\n\n| Usage | Returns |\n|------------------------------------------------|-----------------|\n| ImageCollection.select`(selectors, `*names*`)` | ImageCollection |\n\n| Argument | Type | Details |\n|-------------------------|--------------------------|------------------------------------------------------------------------------------|\n| this: `imagecollection` | ImageCollection | The ImageCollection instance. |\n| `selectors` | List\\\u003cObject\\\u003e | A list of names, regexes or numeric indices specifying the bands to select. |\n| `names` | List\\\u003cString\\\u003e, optional | A list of new names for the output bands. Must match the number of bands selected. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// A Sentinel-2 surface reflectance image collection.\nvar col = ee.ImageCollection('COPERNICUS/S2_SR')\n .filterBounds(ee.Geometry.Point(-122.152, 37.336))\n .filterDate('2021-01-01', '2021-02-01');\nprint('All band names', col.first().bandNames());\n\nprint('Select a band by name',\n col.select('B11').first().bandNames());\n\nprint('Select a band by index',\n col.select(10).first().bandNames());\n\nprint('Select bands using a list',\n col.select(['B11', 'B8', 'B3']).first().bandNames());\n\nprint('Select bands by an argument series',\n col.select('B11', 'B8', 'B3').first().bandNames());\n\nprint('Mixing string and integer selectors is valid',\n col.select(10, 'B8', 2).first().bandNames());\n\nprint('Rename selected bands using two corresponding lists',\n col.select(['B11', 'B8', 'B3'], ['SWIR1', 'NIR', 'Green'])\n .first().bandNames());\n\n// Use regular expressions to select bands.\nprint('Match \"QA\" followed by any two characters',\n col.select('QA..').first().bandNames());\n\nprint('Match \"B\" followed by any character, any number of times',\n col.select('B.*').first().bandNames());\n\nprint('Match \"B\" followed by any character, and any optional third character',\n col.select('B..?').first().bandNames());\n\nprint('Match \"B\" followed by a character in the range 6-8',\n col.select('B[6-8]').first().bandNames());\n\nprint('Match \"B\" followed by a character in the range 1-9 and then 1-2',\n col.select('B[1-9][1-2]').first().bandNames());\n\nprint('Match \"B\" or \"QA\" each followed by any character, any number of times.',\n col.select('B.*|QA.*').first().bandNames());\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 Sentinel-2 surface reflectance image collection.\ncol = ee.ImageCollection('COPERNICUS/S2_SR').filterBounds(\n ee.Geometry.Point(-122.152, 37.336)\n ).filterDate('2021-01-01', '2021-02-01')\nprint('All band names', col.first().bandNames().getInfo())\n\nprint('Select a band by name:',\n col.select('B11').first().bandNames().getInfo())\n\nprint('Select a band by index:',\n col.select(10).first().bandNames().getInfo())\n\nprint('Select bands using a list:',\n col.select(['B11', 'B8', 'B3']).first().bandNames().getInfo())\n\nprint('Select bands by an argument series:',\n col.select('B11', 'B8', 'B3').first().bandNames().getInfo())\n\nprint('Mixing string and integer selectors is valid:',\n col.select(10, 'B8', 2).first().bandNames().getInfo())\n\nprint('Rename selected bands using two corresponding lists:',\n col.select(['B11', 'B8', 'B3'], ['SWIR1', 'NIR', 'Green'])\n .first().bandNames().getInfo())\n\n# Use regular expressions to select bands.\nprint('Match \"QA\" followed by any two characters:',\n col.select('QA..').first().bandNames().getInfo())\n\nprint('Match \"B\" followed by any character, any number of times:',\n col.select('B.*').first().bandNames().getInfo())\n\nprint('Match \"B\" followed by any character, and any optional third character:',\n col.select('B..?').first().bandNames().getInfo())\n\nprint('Match \"B\" followed by a character in the range 6-8:',\n col.select('B[6-8]').first().bandNames().getInfo())\n\nprint('Match \"B\" followed by a character in the range 1-9 and then 1-2:',\n col.select('B[1-9][1-2]').first().bandNames().getInfo())\n\nprint('Match \"B\" or \"QA\" each followed by any character, any number of times:',\n col.select('B.*|QA.*').first().bandNames().getInfo())\n```"]]