ee.Algorithms.If

if-then-else 構造と同様に、条件に基づいて入力のいずれかを選択します。

用途戻り値
ee.Algorithms.If(condition, trueCase, falseCase)オブジェクト
引数タイプ詳細
conditionオブジェクト、デフォルト: null返される結果を決定する条件。ブール値でない場合は、次のルールに従ってブール値として解釈されます。

  • 0 または NaN に等しい数値は false です。
  • 空の文字列、リスト、辞書は false です。
  • Null は false です。
  • その他はすべて true です。
trueCaseオブジェクト、デフォルト: null条件が true の場合に返される結果。
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*"
display(ee.Algorithms.If(False, '*true*', '*false*'))

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

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