ee.Algorithms.If

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

用途戻り値
ee.Algorithms.If(condition, trueCase, falseCase)オブジェクト
引数タイプ詳細
conditionオブジェクト、デフォルト: nullどの結果が返されるかを決定する条件。ブール値でない場合は、次のルールに従ってブール値として解釈されます。
  • 0 または NaN に等しい数値は false です。
  • 空の文字列、リスト、辞書は false です。
  • Null は false です。
  • それ以外はすべて真です。
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*"
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())