Earth Engine 推出了
非商业配额层级 ,以保护共享计算资源并确保为所有人提供可靠的性能。非商业项目默认使用 Community
层级,但您可以随时更改项目的层级。
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 API 和如何使用 geemap 进行交互式开发,请参阅
Python 环境 页面。
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 ))
发送反馈
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可 获得了许可,并且代码示例已根据 Apache 2.0 许可 获得了许可。有关详情,请参阅 Google 开发者网站政策 。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):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"]],["最后更新时间 (UTC):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"]]