ee.ImageCollection.merge
Merges two image collections into one. The result has all the images that were in either collection.
Usage | Returns |
---|
ImageCollection.merge(collection2) | ImageCollection |
Argument | Type | Details |
---|
this: collection1 | ImageCollection | The first collection to merge. |
collection2 | ImageCollection | The second collection to merge. |
Examples
// 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 setup
See the
Python Environment page for information on the Python API and using
geemap
for interactive development.
import ee
import geemap.core as geemap
# 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())
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-10-06 UTC.
[null,null,["Last updated 2023-10-06 UTC."],[[["`merge()` combines two ImageCollections, resulting in a new collection containing all images from both inputs."],["The output of `merge()` is a new ImageCollection with no duplicates."],["This 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."]]],["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"]]