Image collection overview
Getting Started with Earth Engine ImageCollection
As illustrated in the Get Started section and the ImageCollection Information section, Earth Engine provides a variety of convenience methods for filtering image collections. Specifically, many common use cases are handled by imageCollection.filterDate()
, and imageCollection.filterBounds()
. For general purpose filtering, use imageCollection.filter()
with an ee.Filter as an argument. The following example demonstrates both convenience methods and filter()
to identify and remove images with bad registration from an ImageCollection
:
In [1]:
Copied!
import ee
import geemap
import ee
import geemap
In [2]:
Copied!
Map = geemap.Map()
Map
Map = geemap.Map()
Map
Out[2]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Get collection size¶
In [3]:
Copied!
collection = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
collection = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
In [4]:
Copied!
print(collection.size().getInfo())
print(collection.size().getInfo())
1233209
Get the first image¶
In [5]:
Copied!
image = collection.first()
geemap.image_props(image).getInfo()
image = collection.first()
geemap.image_props(image).getInfo()
Out[5]:
{'CLOUD_COVER': 88.55, 'CLOUD_COVER_LAND': 38.2, 'EARTH_SUN_DISTANCE': 1.012707, 'ESPA_VERSION': '2_23_0_1a', 'GEOMETRIC_RMSE_MODEL': 7.666, 'GEOMETRIC_RMSE_MODEL_X': 5.483, 'GEOMETRIC_RMSE_MODEL_Y': 5.358, 'IMAGE_DATE': '2014-05-24', 'IMAGE_QUALITY_OLI': 9, 'IMAGE_QUALITY_TIRS': 9, 'LANDSAT_ID': 'LC08_L1TP_001004_20140524_20170422_01_T1', 'LEVEL1_PRODUCTION_DATE': 1492857311000, 'NOMINAL_SCALE': 30, 'PIXEL_QA_VERSION': 'generate_pixel_qa_1.6.0', 'SATELLITE': 'LANDSAT_8', 'SENSING_TIME': '2014-05-24T14:07:53.5175160Z', 'SOLAR_AZIMUTH_ANGLE': -161.343674, 'SOLAR_ZENITH_ANGLE': 57.854137, 'SR_APP_VERSION': 'LaSRC_1.3.0', 'WRS_PATH': 1, 'WRS_ROW': 4, 'system:asset_size': '633.527205 MB', 'system:band_names': ['B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B10', 'B11', 'sr_aerosol', 'pixel_qa', 'radsat_qa'], 'system:id': 'LANDSAT/LC08/C01/T1_SR/LC08_001004_20140524', 'system:index': 'LC08_001004_20140524', 'system:time_end': '2014-05-24 14:07:53', 'system:time_start': '2014-05-24 14:07:53', 'system:version': 1522727451594601}
In [6]:
Copied!
Map.addLayer(image, {}, "First image")
Map.centerObject(image, 6)
Map
Map.addLayer(image, {}, "First image")
Map.centerObject(image, 6)
Map
Out[6]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [7]:
Copied!
collection = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR').filterDate(
'2020-01-01', '2020-12-31'
)
collection = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR').filterDate(
'2020-01-01', '2020-12-31'
)
In [8]:
Copied!
print(collection.size().getInfo())
print(collection.size().getInfo())
140225
In [9]:
Copied!
image2 = collection.first()
Map.addLayer(image2, {}, "Another image")
Map.centerObject(image2, 6)
Map
image2 = collection.first()
Map.addLayer(image2, {}, "Another image")
Map.centerObject(image2, 6)
Map
Out[9]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [10]:
Copied!
roi = ee.Geometry.Point(-122.4488, 37.7589)
roi = ee.Geometry.Point(-122.4488, 37.7589)
In [11]:
Copied!
collection = (
ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
.filterDate('2020-01-01', '2020-12-31')
.filterBounds(roi)
)
collection = (
ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
.filterDate('2020-01-01', '2020-12-31')
.filterBounds(roi)
)
In [12]:
Copied!
print(collection.size().getInfo())
print(collection.size().getInfo())
21
In [13]:
Copied!
Map = geemap.Map()
image = collection.first()
vis_param = {'min': 0, 'max': 2000, 'bands': ['B5', 'B4', 'B3'], 'gamma': 1.5}
Map.addLayer(image, vis_param, "First mage")
Map.centerObject(image, 8)
Map
Map = geemap.Map()
image = collection.first()
vis_param = {'min': 0, 'max': 2000, 'bands': ['B5', 'B4', 'B3'], 'gamma': 1.5}
Map.addLayer(image, vis_param, "First mage")
Map.centerObject(image, 8)
Map
Out[13]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [14]:
Copied!
collection = (
ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
.filterDate('2020-01-01', '2020-12-31')
.filterBounds(ee.Geometry.Point(-122.4488, 37.7589))
.filterMetadata('CLOUD_COVER', 'less_than', 10)
.sort("CLOUD_COVER")
)
collection = (
ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
.filterDate('2020-01-01', '2020-12-31')
.filterBounds(ee.Geometry.Point(-122.4488, 37.7589))
.filterMetadata('CLOUD_COVER', 'less_than', 10)
.sort("CLOUD_COVER")
)
In [15]:
Copied!
Map = geemap.Map()
image = collection.first()
vis_param = {'min': 0, 'max': 2000, 'bands': ['B5', 'B4', 'B3'], 'gamma': 1.5}
Map.addLayer(image, vis_param, "First mage")
Map.centerObject(image, 8)
Map
Map = geemap.Map()
image = collection.first()
vis_param = {'min': 0, 'max': 2000, 'bands': ['B5', 'B4', 'B3'], 'gamma': 1.5}
Map.addLayer(image, vis_param, "First mage")
Map.centerObject(image, 8)
Map
Out[15]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [16]:
Copied!
geemap.image_props(image).getInfo()
geemap.image_props(image).getInfo()
Out[16]:
{'CLOUD_COVER': 0.07, 'CLOUD_COVER_LAND': 0.1, 'EARTH_SUN_DISTANCE': 0.997823, 'ESPA_VERSION': '2_23_0_1b', 'GEOMETRIC_RMSE_MODEL': 6.867, 'GEOMETRIC_RMSE_MODEL_X': 4.673, 'GEOMETRIC_RMSE_MODEL_Y': 5.031, 'IMAGE_DATE': '2020-10-12', 'IMAGE_QUALITY_OLI': 9, 'IMAGE_QUALITY_TIRS': 9, 'LANDSAT_ID': 'LC08_L1TP_044034_20201012_20201104_01_T1', 'LEVEL1_PRODUCTION_DATE': 1604502607000, 'NOMINAL_SCALE': 30, 'PIXEL_QA_VERSION': 'generate_pixel_qa_1.6.0', 'SATELLITE': 'LANDSAT_8', 'SENSING_TIME': '2020-10-12T18:46:24.8043990Z', 'SOLAR_AZIMUTH_ANGLE': 156.943848, 'SOLAR_ZENITH_ANGLE': 47.988567, 'SR_APP_VERSION': 'LaSRC_1.3.0', 'WRS_PATH': 44, 'WRS_ROW': 34, 'system:asset_size': '556.916351 MB', 'system:band_names': ['B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B10', 'B11', 'sr_aerosol', 'pixel_qa', 'radsat_qa'], 'system:id': 'LANDSAT/LC08/C01/T1_SR/LC08_044034_20201012', 'system:index': 'LC08_044034_20201012', 'system:time_end': '2020-10-12 18:46:24', 'system:time_start': '2020-10-12 18:46:24', 'system:version': 1604744200215236}
Get image collection properties¶
In [17]:
Copied!
collection = (
ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
.filterDate('2020-01-01', '2020-12-31')
.filterBounds(ee.Geometry.Point(-122.4488, 37.7589))
.filterMetadata('CLOUD_COVER', 'less_than', 10)
)
collection = (
ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
.filterDate('2020-01-01', '2020-12-31')
.filterBounds(ee.Geometry.Point(-122.4488, 37.7589))
.filterMetadata('CLOUD_COVER', 'less_than', 10)
)
In [18]:
Copied!
collection.aggregate_array('CLOUD_COVER').getInfo()
collection.aggregate_array('CLOUD_COVER').getInfo()
Out[18]:
[0.55, 0.46, 6.53, 0.07, 2.96, 0.55]
In [19]:
Copied!
collection.aggregate_array('system:id').getInfo()
collection.aggregate_array('system:id').getInfo()
Out[19]:
['LANDSAT/LC08/C01/T1_SR/LC08_044034_20200302', 'LANDSAT/LC08/C01/T1_SR/LC08_044034_20200403', 'LANDSAT/LC08/C01/T1_SR/LC08_044034_20200606', 'LANDSAT/LC08/C01/T1_SR/LC08_044034_20201012', 'LANDSAT/LC08/C01/T1_SR/LC08_044034_20201028', 'LANDSAT/LC08/C01/T1_SR/LC08_044034_20201129']
In [20]:
Copied!
collection.aggregate_mean('CLOUD_COVER').getInfo()
collection.aggregate_mean('CLOUD_COVER').getInfo()
Out[20]:
1.8533333333333335
Last update:
2022-03-25