お知らせ:
2025 年 4 月 15 日より前に Earth Engine の使用を登録したすべての非商用プロジェクトは、アクセスを維持するために
非商用目的での利用資格を確認する必要があります。2025 年 9 月 26 日までに確認が完了していない場合、アクセスが保留されることがあります。
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())
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-07-26 UTC。
[null,null,["最終更新日 2025-07-26 UTC。"],[],["The `ee.Algorithms.If` function selects one of two inputs based on a condition. It takes a `condition`, `trueCase`, and `falseCase`. If the `condition` is true, it returns `trueCase`; otherwise, it returns `falseCase`. Non-boolean conditions are evaluated: 0, NaN, empty collections, and null are false; everything else is true. Examples show using boolean values and string comparisons as conditions to determine the returned value. The `remap` function is suggested as an alternative for class-numbering tasks.\n"]]