ee.ImageCollection.sort

지정된 속성별로 컬렉션을 정렬합니다.

정렬된 컬렉션을 반환합니다.

사용반환 값
ImageCollection.sort(property, ascending)컬렉션
인수유형세부정보
다음과 같은 경우: collection컬렉션컬렉션 인스턴스입니다.
property문자열정렬할 속성입니다.
ascending불리언, 선택사항오름차순으로 정렬할지 내림차순으로 정렬할지입니다. 기본값은 true (오름차순)입니다.

코드 편집기 (JavaScript)

// A Landsat 8 TOA image collection (2 months of images at a specific point).
var col = ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')
  .filterBounds(ee.Geometry.Point(-90.70, 34.71))
  .filterDate('2020-07-01', '2020-09-01');
print('Collection', col);

// Sort the collection in ASCENDING order of image cloud cover.
var colCldSortAsc = col.sort('CLOUD_COVER');
print('Cloud cover ascending', colCldSortAsc);

// Display the image with the least cloud cover.
var visParams = {
  bands: ['B4', 'B3', 'B2'],
  min: 0.01,
  max: 0.25
};
Map.setCenter(-90.70, 34.71, 9);
Map.addLayer(colCldSortAsc.first(), visParams, 'Least cloudy');

// Sort the collection in DESCENDING order of image cloud cover.
var colCldSortDesc = col.sort('CLOUD_COVER', false);
print('Cloud cover descending', colCldSortDesc);

// Display the image with the most cloud cover.
Map.addLayer(colCldSortDesc.first(), visParams, 'Most cloudy');

Python 설정

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

import ee
import geemap.core as geemap

Colab (Python)

# A Landsat 8 TOA image collection (2 months of images at a specific point).
col = (
    ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')
    .filterBounds(ee.Geometry.Point(-90.70, 34.71))
    .filterDate('2020-07-01', '2020-09-01')
)
display('Collection', col)

# Sort the collection in ASCENDING order of image cloud cover.
col_cld_sort_asc = col.sort('CLOUD_COVER')
display('Cloud cover ascending', col_cld_sort_asc)

# Display the image with the least cloud cover.
vis_params = {'bands': ['B4', 'B3', 'B2'], 'min': 0.01, 'max': 0.25}
m = geemap.Map()
m.set_center(-90.70, 34.71, 9)
m.add_layer(col_cld_sort_asc.first(), vis_params, 'Least cloudy')

# Sort the collection in DESCENDING order of image cloud cover.
col_cld_sort_desc = col.sort('CLOUD_COVER', False)
display('Cloud cover descending', col_cld_sort_desc)

# Display the image with the most cloud cover.
m.add_layer(col_cld_sort_desc.first(), vis_params, 'Most cloudy')
m