Earth Engine sẽ giới thiệu
các bậc hạn mức phi thương mại để bảo vệ các tài nguyên điện toán dùng chung và đảm bảo hiệu suất đáng tin cậy cho mọi người. Tất cả các dự án phi thương mại đều cần chọn một cấp hạn mức muộn nhất vào
ngày 27 tháng 4 năm 2026, nếu không sẽ sử dụng Cấp cộng đồng theo mặc định. Hạn mức theo cấp sẽ có hiệu lực đối với tất cả các dự án (bất kể ngày chọn cấp) từ
ngày 27 tháng 4 năm 2026.
Tìm hiểu thêm.
ee.Number.expression
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Tính toán một biểu thức số.
| Cách sử dụng | Giá trị trả về |
|---|
ee.Number.expression(expression, vars) | Số |
| Đối số | Loại | Thông tin chi tiết |
|---|
expression | Chuỗi | Một chuỗi biểu thức toán học cần được đánh giá. Ngoài các toán tử số học, boolean và quan hệ tiêu chuẩn, biểu thức cũng hỗ trợ mọi hàm trong Số, toán tử "." để trích xuất các phần tử con từ từ điển "vars" và các hằng số toán học Math.PI và Math.E. |
vars | Từ điển, mặc định: null | Một từ điển gồm các giá trị được đặt tên có thể dùng trong biểu thức. |
Ví dụ
Trình soạn thảo mã (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));
Thiết lập Python
Hãy xem trang
Môi trường Python để biết thông tin về API Python và cách sử dụng geemap cho quá trình phát triển tương tác.
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))
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-10-30 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-10-30 UTC."],[],["`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"]]