Announcement: All noncommercial projects registered to use Earth Engine before April 15, 2025 must verify noncommercial eligibility to maintain access. If you have not verified by September 26, 2025, your access may be on hold.
Stay organized with collections
Save and categorize content based on your preferences.
AI-generated Key Takeaways
ee.Algorithms.If selects one of two input values based on a given condition, similar to an if-then-else statement.
The condition input determines the output, treating non-boolean values as true or false based on specific rules (e.g., 0 is false, empty strings are false).
trueCase and falseCase represent the values returned when the condition is true or false, respectively.
While ee.Algorithms.If is versatile, using remap might be more efficient for tasks like assigning numerical values to classes.
Selects one of its inputs based on a condition, similar to an if-then-else construct.
Usage
Returns
ee.Algorithms.If(condition, trueCase, falseCase)
Object
Argument
Type
Details
condition
Object, default: null
The condition that determines which result is returned. If this is not a boolean, it is interpreted as a boolean by the following rules:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-19 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"]]