ee.ImageCollection.first
Returns the first entry from a given collection.
Usage | Returns |
---|
ImageCollection.first() | Image |
Argument | Type | Details |
---|
this: imagecollection | ImageCollection | The ImageCollection instance. |
Examples
var image = ee.ImageCollection('COPERNICUS/S2_SR').first();
Map.centerObject(image, 8);
var vis = {bands: ['B4', 'B3', 'B2'], min: 0, max: 5000};
Map.addLayer(image, vis, 'first of S2_SR');
// Display the image metadata.
print(image);
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
image = ee.ImageCollection('COPERNICUS/S2_SR').first()
m = geemap.Map()
m.center_object(image, 8)
vis = {'bands': ['B4', 'B3', 'B2'], 'min': 0, 'max': 5000}
m.add_layer(image, vis, 'first of S2_SR')
display(m)
# Display the image metadata.
display(image)
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."],[[["The `first()` function retrieves the first image from an ImageCollection in Earth Engine."],["It can be applied to any ImageCollection, like the 'COPERNICUS/S2_SR' dataset shown in the examples."],["Users can then visualize and analyze this single image, displaying its metadata or adding it as a layer to a map."],["The provided code demonstrates using `first()` in both JavaScript and Python environments within the Google Earth Engine Code Editor and Colab."]]],["The provided content describes the `.first()` method for an ImageCollection, which retrieves the initial Image within that collection. In JavaScript and Python examples, it's demonstrated by selecting the first image from the 'COPERNICUS/S2_SR' ImageCollection. The code then centers the map on this image, sets visualization parameters, displays it on the map, and prints the image's metadata. This method only takes the ImageCollection instance as input.\n"]]