Earth Engine 已推出
非商業用途的配額級別 ,以便保護共用運算資源,並確保所有使用者都能享有穩固效能。非商業用途的專案預設會使用「社群」級別,但您隨時可以變更專案級別。
Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
提供意見
ee.Number.expression
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
計算數字運算式。
用量 傳回 ee.Number.expression(expression, vars )數字
引數 類型 詳細資料 expression字串 要評估的數學運算式字串。除了標準算術、布林和關係運算子,運算式也支援 Number 中的任何函式、從「vars」字典擷取子元素的「.」運算子,以及數學常數 Math.PI 和 Math.E。 vars字典,預設值:null 可在運算式中使用的具名值字典。
範例
程式碼編輯器 (JavaScript)
// A dictionary of variables to use in expression.
var variables = { x : 5 , y : 10 };
// Arithmetic operators.
print ( 'x + y' ,
ee . Number . expression ( 'x + y' , variables ));
print ( 'x - y' ,
ee . Number . expression ( 'x - y' , variables ));
print ( 'x * y' ,
ee . Number . expression ( 'x * y' , variables ));
print ( 'x / y' ,
ee . Number . expression ( 'x / y' , variables ));
print ( 'x ** y' ,
ee . Number . expression ( 'x ** y' , variables ));
print ( 'x % y' ,
ee . Number . expression ( 'x % y' , variables ));
// Logical operators.
print ( 'x || y' ,
ee . Number . expression ( 'x || y' , variables ));
print ( 'x && y' ,
ee . Number . expression ( 'x && y' , variables ));
print ( '!(x)' ,
ee . Number . expression ( '!(x)' , variables ));
// Relational operators.
print ( 'x > y' ,
ee . Number . expression ( 'x > y' , variables ));
print ( 'x >= y' ,
ee . Number . expression ( 'x >= y' , variables ));
print ( 'x < y' ,
ee . Number . expression ( 'x < y' , variables ));
print ( 'x <= y' ,
ee . Number . expression ( 'x <= y' , variables ));
print ( 'x == y' ,
ee . Number . expression ( 'x == y' , variables ));
print ( 'x != y' ,
ee . Number . expression ( 'x != y' , variables ));
// Conditional (ternary) operator.
print ( '(x < y) ? 100 : 1000)' ,
ee . Number . expression ( '(x < y) ? 100 : 1000' , variables ));
// Constants in the expression.
print ( '100 * (x + y)' ,
ee . Number . expression ( '100 * (x + y)' , variables ));
// JavaScript Math constants.
print ( 'Math.PI' ,
ee . Number . expression ( 'Math.PI' , null ));
print ( 'Math.E' ,
ee . Number . expression ( 'Math.E' , null ));
// Dot notation to call on child elements.
print ( 'Use dot notation to call on child elements' ,
ee . Number . expression ( 'vals.x * vals.y' , { vals : variables }));
// ee.Number functions.
print ( 'Use ee.Number add: add(x, y)' ,
ee . Number . expression ( 'add(x, y)' , variables ));
print ( 'Use ee.Number add and subtract: subtract(add(x, y), 5)' ,
ee . Number . expression ( 'subtract(add(x, y), 5)' , variables ));
Python 設定
請參閱
Python 環境 頁面,瞭解 Python API 和如何使用 geemap 進行互動式開發。
import ee
import geemap.core as geemap
Colab (Python)
# A dictionary of variables to use in expression.
variables = { 'x' : 5 , 'y' : 10 }
# Arithmetic operators.
display ( 'x + y:' ,
ee . Number . expression ( 'x + y' , variables ))
display ( 'x - y:' ,
ee . Number . expression ( 'x - y' , variables ))
display ( 'x * y:' ,
ee . Number . expression ( 'x * y' , variables ))
display ( 'x / y:' ,
ee . Number . expression ( 'x / y' , variables ))
display ( 'x ** y:' ,
ee . Number . expression ( 'x ** y' , variables ))
display ( 'x % y:' ,
ee . Number . expression ( 'x % y' , variables ))
# Logical operators.
display ( 'x || y:' ,
ee . Number . expression ( 'x || y' , variables ))
display ( 'x && y:' ,
ee . Number . expression ( 'x && y' , variables ))
display ( '!(x):' ,
ee . Number . expression ( '!(x)' , variables ))
# Relational operators.
display ( 'x > y:' ,
ee . Number . expression ( 'x > y' , variables ))
display ( 'x >= y:' ,
ee . Number . expression ( 'x >= y' , variables ))
display ( 'x < y:' ,
ee . Number . expression ( 'x < y' , variables ))
display ( 'x <= y:' ,
ee . Number . expression ( 'x <= y' , variables ))
display ( 'x == y:' ,
ee . Number . expression ( 'x == y' , variables ))
display ( 'x != y:' ,
ee . Number . expression ( 'x != y' , variables ))
# Conditional JavaScript (ternary) operator.
display ( '(x < y) ? 100 : 1000):' ,
ee . Number . expression ( '(x < y) ? 100 : 1000' , variables ))
# Constants in the expression.
display ( '100 * (x + y):' ,
ee . Number . expression ( '100 * (x + y)' , variables ))
# JavaScript Math constants.
display ( 'Math.PI:' ,
ee . Number . expression ( 'Math.PI' , None ))
display ( 'Math.E:' ,
ee . Number . expression ( 'Math.E' , None ))
# Dot notation to call on child elements.
display ( 'Use dot notation to call on child elements:' ,
ee . Number . expression ( 'vals.x * vals.y' , { 'vals' : variables }))
# ee.Number functions.
display ( 'Use ee.Number add. add(x, y):' ,
ee . Number . expression ( 'add(x, y)' , variables ))
display ( 'Use ee.Number add and subtract. subtract(add(x, y), 5):' ,
ee . Number . expression ( 'subtract(add(x, y), 5)' , variables ))
提供意見
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權 ,程式碼範例則為阿帕契 2.0 授權 。詳情請參閱《Google Developers 網站政策 》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-10-30 (世界標準時間)。
想進一步說明嗎?
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-10-30 (世界標準時間)。"],[],["`ee.Number.expression` evaluates a mathematical expression string. It accepts an `expression` string and an optional `vars` dictionary containing named values. The expression supports arithmetic, boolean, and relational operators, as well as functions found in `ee.Number` and constants like `Math.PI` and `Math.E`. Dot notation accesses nested dictionary elements. The function returns a numerical result, allowing complex computations. Examples include adding, subtracting, multiplying, applying logical operations, and conditional logic.\n"]]