公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ee.ImageCollection.merge
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
将两个图片集合合并为一个。结果包含两个集合中的所有图片。
用法 | 返回 |
---|
ImageCollection.merge(collection2) | ImageCollection |
参数 | 类型 | 详细信息 |
---|
此:collection1 | ImageCollection | 要合并的第一个集合。 |
collection2 | ImageCollection | 要合并的第二个集合。 |
示例
代码编辑器 (JavaScript)
// Sentinel-2 surface reflectance image collection.
var ic = ee.ImageCollection('COPERNICUS/S2_SR');
// Filter the images to those that intersect Mount Shasta for 3 months
// in 2019 and 2021 (two image collections).
var geom = ee.Geometry.Point(-122.196, 41.411);
var ic2018 = ic.filterBounds(geom).filterDate('2019-07-01', '2019-10-01');
print('2018 image collection', ic2018);
var ic2021 = ic.filterBounds(geom).filterDate('2021-07-01', '2021-10-01');
print('2021 image collection', ic2021);
// Merge the two image collections.
var icMerged = ic2018.merge(ic2021);
print('Merged image collection', icMerged);
Python 设置
如需了解 Python API 和如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
# Sentinel-2 surface reflectance image collection.
ic = ee.ImageCollection('COPERNICUS/S2_SR')
# Filter the images to those that intersect Mount Shasta for 3 months
# in 2019 and 2021 (two image collections).
geom = ee.Geometry.Point(-122.196, 41.411)
ic2018 = ic.filterBounds(geom).filterDate('2019-07-01', '2019-10-01')
print('2018 image collection:', ic2018.getInfo())
ic2021 = ic.filterBounds(geom).filterDate('2021-07-01', '2021-10-01')
print('2021 image collection:', ic2021.getInfo())
# Merge the two image collections.
ic_merged = ic2018.merge(ic2021)
print('Merged image collection:', ic_merged.getInfo())
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003e\u003ccode\u003emerge()\u003c/code\u003e combines two ImageCollections, resulting in a new collection containing all images from both inputs.\u003c/p\u003e\n"],["\u003cp\u003eThe output of \u003ccode\u003emerge()\u003c/code\u003e is a new ImageCollection with no duplicates.\u003c/p\u003e\n"],["\u003cp\u003eThis function is useful for consolidating image collections filtered by different criteria, such as date ranges or regions, as shown in the example with Sentinel-2 imagery filtered for different years.\u003c/p\u003e\n"]]],["The `merge` method combines two `ImageCollection` objects, `collection1` and `collection2`, into a single `ImageCollection`. This resulting collection contains all images from both input collections. The method takes `collection2` as an argument. An example filters a Sentinel-2 collection for 2019 and 2021, then merges these two filtered collections using `merge(ic2021)`. The output is a new collection containing images from both time periods.\n"],null,["# ee.ImageCollection.merge\n\nMerges two image collections into one. The result has all the images that were in either collection.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|--------------------------------------|-----------------|\n| ImageCollection.merge`(collection2)` | ImageCollection |\n\n| Argument | Type | Details |\n|---------------------|-----------------|---------------------------------|\n| this: `collection1` | ImageCollection | The first collection to merge. |\n| `collection2` | ImageCollection | The second collection to merge. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// Sentinel-2 surface reflectance image collection.\nvar ic = ee.ImageCollection('COPERNICUS/S2_SR');\n\n// Filter the images to those that intersect Mount Shasta for 3 months\n// in 2019 and 2021 (two image collections).\nvar geom = ee.Geometry.Point(-122.196, 41.411);\nvar ic2018 = ic.filterBounds(geom).filterDate('2019-07-01', '2019-10-01');\nprint('2018 image collection', ic2018);\nvar ic2021 = ic.filterBounds(geom).filterDate('2021-07-01', '2021-10-01');\nprint('2021 image collection', ic2021);\n\n// Merge the two image collections.\nvar icMerged = ic2018.merge(ic2021);\nprint('Merged image collection', icMerged);\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# Sentinel-2 surface reflectance image collection.\nic = ee.ImageCollection('COPERNICUS/S2_SR')\n\n# Filter the images to those that intersect Mount Shasta for 3 months\n# in 2019 and 2021 (two image collections).\ngeom = ee.Geometry.Point(-122.196, 41.411)\nic2018 = ic.filterBounds(geom).filterDate('2019-07-01', '2019-10-01')\nprint('2018 image collection:', ic2018.getInfo())\nic2021 = ic.filterBounds(geom).filterDate('2021-07-01', '2021-10-01')\nprint('2021 image collection:', ic2021.getInfo())\n\n# Merge the two image collections.\nic_merged = ic2018.merge(ic2021)\nprint('Merged image collection:', ic_merged.getInfo())\n```"]]