ImageCollection 필터링

시작하기 섹션ImageCollection 정보 섹션에 설명된 대로 Earth Engine은 이미지 컬렉션을 필터링하는 다양한 편의 메서드를 제공합니다. 특히 많은 일반적인 사용 사례는 imageCollection.filterDate()imageCollection.filterBounds()로 처리됩니다. 범용 필터링의 경우 ee.Filter를 인수로 사용하여 imageCollection.filter()를 사용합니다. 다음 예에서는 편의 메서드와 filter()를 모두 사용하여 ImageCollection에서 구름이 많은 이미지를 식별하고 삭제하는 방법을 보여줍니다.

코드 편집기 (JavaScript)

// Load Landsat 8 data, filter by date, month, and bounds.
var collection = ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')
  .filterDate('2015-01-01', '2018-01-01')  // Three years of data
  .filter(ee.Filter.calendarRange(11, 2, 'month'))  // Only Nov-Feb observations
  .filterBounds(ee.Geometry.Point(25.8544, -18.08874));  // Intersecting ROI

// Also filter the collection by the CLOUD_COVER property.
var filtered = collection.filter(ee.Filter.eq('CLOUD_COVER', 0));

// Create two composites to check the effect of filtering by CLOUD_COVER.
var badComposite = collection.mean();
var goodComposite = filtered.mean();

// Display the composites.
Map.setCenter(25.8544, -18.08874, 13);
Map.addLayer(badComposite,
             {bands: ['B3', 'B2', 'B1'], min: 0.05, max: 0.35, gamma: 1.1},
             'Bad composite');
Map.addLayer(goodComposite,
             {bands: ['B3', 'B2', 'B1'], min: 0.05, max: 0.35, gamma: 1.1},
             'Good composite');

Python 설정

Python API 및 대화형 개발을 위한 geemap 사용에 관한 자세한 내용은 Python 환경 페이지를 참고하세요.

import ee
import geemap.core as geemap

Colab (Python)

# Load Landsat 8 data, filter by date, month, and bounds.
collection = (
    ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')
    # Three years of data
    .filterDate('2015-01-01', '2018-01-01')
    # Only Nov-Feb observations
    .filter(ee.Filter.calendarRange(11, 2, 'month'))
    # Intersecting ROI
    .filterBounds(ee.Geometry.Point(25.8544, -18.08874))
)

# Also filter the collection by the CLOUD_COVER property.
filtered = collection.filter(ee.Filter.eq('CLOUD_COVER', 0))

# Create two composites to check the effect of filtering by CLOUD_COVER.
bad_composite = collection.mean()
good_composite = filtered.mean()

# Display the composites.
m = geemap.Map()
m.set_center(25.8544, -18.08874, 13)
m.add_layer(
    bad_composite,
    {'bands': ['B3', 'B2', 'B1'], 'min': 0.05, 'max': 0.35, 'gamma': 1.1},
    'Bad composite',
)
m.add_layer(
    good_composite,
    {'bands': ['B3', 'B2', 'B1'], 'min': 0.05, 'max': 0.35, 'gamma': 1.1},
    'Good composite',
)
m