Announcement: All noncommercial projects registered to use Earth Engine beforeApril 15, 2025 mustverify noncommercial eligibility to maintain access. If you have not verified by September 26, 2025, your access may be on hold.

ee.ImageCollection.fromImages

  • Theee.ImageCollection.fromImages() function creates an image collection from a given list of images.

  • This function is particularly useful for coercing ambiguous image lists obtained from server-side objects into an image collection.

  • A common use case is converting an image list resulting from asaveAll join operation into an image collection.

Returns the image collection containing the given images.

UsageReturns
ee.ImageCollection.fromImages(images)ImageCollection
ArgumentTypeDetails
imagesListThe images to include in the collection.

Examples

Code Editor (JavaScript)

// A series of images.varimg1=ee.Image(0);varimg2=ee.Image(1);varimg3=ee.Image(2);// Convert the list of images into an image collection.varcol=ee.ImageCollection.fromImages([img1,img2,img3]);print('Collection from list of images',col);// The ee.ImageCollection.fromImages function is intended to coerce the image// list to a collection when the list is an ambiguous, computed object fetched// from the properties of a server-side object. For instance, a list// of images retrieved from a ee.Feature property. Here, we set an image// list as a property of a feature, retrieve it, and convert it to// a collection. Notice that the ee.ImageCollection constructor fails to coerce// the image list to a collection, but ee.ImageCollection.fromImages does.varfeature=ee.Feature(null).set('img_list',[img1,img2,img3]);varambiguousImgList=feature.get('img_list');print('Coerced to collection',ee.ImageCollection.fromImages(ambiguousImgList));print('NOT coerced to collection',ee.ImageCollection(ambiguousImgList));// A common use case is coercing an image list from a saveAll join to a// image collection, like in this example of building a collection of mean// annual NDVI images from a MODIS collection.varmodisCol=ee.ImageCollection('MODIS/061/MOD13A2').filterDate('2017','2021').select('NDVI').map(function(img){returnimg.set('year',img.date().get('year'))});vardistinctYearCol=modisCol.distinct('year');varjoinedCol=ee.Join.saveAll('img_list').apply({primary:distinctYearCol,secondary:modisCol,condition:ee.Filter.equals({'leftField':'year','rightField':'year'})});varannualNdviMean=joinedCol.map(function(img){returnee.ImageCollection.fromImages(img.get('img_list')).mean().copyProperties(img,['year']);});print('Mean annual NDVI collection',annualNdviMean);

Python setup

See the Python Environment page for information on the Python API and usinggeemap for interactive development.

importeeimportgeemap.coreasgeemap

Colab (Python)

# A series of images.img1=ee.Image(0)img2=ee.Image(1)img3=ee.Image(2)# Convert the list of images into an image collection.col=ee.ImageCollection.fromImages([img1,img2,img3])display('Collection from list of images:',col)# The ee.ImageCollection.fromImages function is intended to coerce the image# list to a collection when the list is an ambiguous, computed object fetched# from the properties of a server-side object. For instance, a list# of images retrieved from a ee.Feature property. Here, we set an image# list as a property of a feature, retrieve it, and convert it to# a collection. Notice that the ee.ImageCollection constructor fails to coerce# the image list to a collection, but ee.ImageCollection.fromImages does.feature=ee.Feature(None).set('img_list',[img1,img2,img3])ambiguous_img_list=feature.get('img_list')display('Coerced to collection:',ee.ImageCollection.fromImages(ambiguous_img_list),)display('NOT coerced to collection:',ee.ImageCollection(ambiguous_img_list),)# A common use case is coercing an image list from a saveAll join to a# image collection, like in this example of building a collection of mean# annual NDVI images from a MODIS collection.modis_col=(ee.ImageCollection('MODIS/061/MOD13A2').filterDate('2017','2021').select('NDVI').map(lambdaimg:img.set('year',img.date().get('year'))))distinct_year_col=modis_col.distinct('year')joined_col=ee.Join.saveAll('img_list').apply(primary=distinct_year_col,secondary=modis_col,condition=ee.Filter.equals(leftField='year',rightField='year'),)annual_ndvi_mean=joined_col.map(lambdaimg:ee.ImageCollection.fromImages(img.get('img_list')).mean().copyProperties(img,['year']))display('Mean annual NDVI collection:',annual_ndvi_mean)

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2023-10-06 UTC.