ב-Earth Engine הוספנו
רמות מכסת שימוש לא מסחרי כדי להגן על משאבי מחשוב משותפים ולספק ביצועים מהימנים לכולם. בפרויקטים לא מסחריים נעשה שימוש במסלול Community כברירת מחדל, אבל אפשר לשנות את המסלול של הפרויקט בכל שלב.
Google משתמשת בטכנולוגיית AI כדי לתרגם תוכן לשפה המועדפת עליך. בתרגומים כאלו עשויות להיות שגיאות.
ee.Algorithms.If
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
בוחר אחד מהקלטות שלו על סמך תנאי, בדומה למבנה if-then-else.
| שימוש | החזרות |
|---|
ee.Algorithms.If(condition, trueCase, falseCase) | אובייקט |
| ארגומנט | סוג | פרטים |
|---|
condition | אובייקט, ברירת מחדל: null | התנאי שקובע איזו תוצאה תוחזר. אם הערך הוא לא בוליאני, הוא יפורש כבוליאני לפי הכללים הבאים: - מספרים ששווים ל-0 או ל-NaN הם בעלי הערך 'שקר'.
- מחרוזות ריקות, רשימות ומילונים הם False.
- הערך Null הוא False.
- כל השאר נכון.
|
trueCase | אובייקט, ברירת מחדל: null | התוצאה שמוחזרת אם התנאי מתקיים. |
falseCase | אובייקט, ברירת מחדל: null | התוצאה שמוחזרת אם התנאי לא מתקיים. |
דוגמאות
Code Editor (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 מפורט מידע על Python API ועל השימוש ב-geemap לפיתוח אינטראקטיבי.
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))
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2026-04-20 (שעון UTC).
[null,null,["עדכון אחרון: 2026-04-20 (שעון 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"]]