ee.Algorithms.If

는 if-then-else 구조와 유사하게 조건에 따라 입력 중 하나를 선택합니다.

사용반환 값
ee.Algorithms.If(condition, trueCase, falseCase)객체
인수유형세부정보
condition객체, 기본값: null반환되는 결과를 결정하는 조건입니다. 부울이 아닌 경우 다음 규칙에 따라 부울로 해석됩니다.
  • 0 또는 NaN과 같은 숫자는 false입니다.
  • 빈 문자열, 목록, 사전은 false입니다.
  • Null은 false입니다.
  • 그 외에는 모두 사실입니다.
trueCase객체, 기본값: null조건이 참인 경우 반환되는 결과입니다.
falseCase객체, 기본값: null조건이 false인 경우 반환할 결과입니다.

코드 편집기 (JavaScript)

print(ee.Algorithms.If(false, '*true*', '*false*'));  // The string "*false*"
print(ee.Algorithms.If(true, '*true*', '*false*'));  // The string "*true*"

// Consider using remap rather than If for tasks like numbers for classes.
print(ee.Algorithms.If(ee.String('Tree').compareTo('Tree'), 0, 1));
print(ee.Algorithms.If(ee.String('NotTree').compareTo('Tree'), 0, 1));

Python 설정

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

import ee
import geemap.core as geemap

Colab (Python)

# The string "*false*"
print(ee.Algorithms.If(False, '*true*', '*false*').getInfo())

# The string "*true*"
print(ee.Algorithms.If(True, '*true*', '*false*').getInfo())

# Consider using remap rather than If for tasks like numbers for classes.
print(ee.Algorithms.If(ee.String('Tree').compareTo('Tree'), 0, 1).getInfo())
print(ee.Algorithms.If(ee.String('NotTree').compareTo('Tree'), 0, 1).getInfo())