Wprowadzamy w Earth Engine
poziomy limitów niekomercyjnych, aby chronić współdzielone zasoby obliczeniowe i zapewnić niezawodną wydajność dla wszystkich. We wszystkich projektach niekomercyjnych trzeba będzie wybrać poziom limitu do
27 kwietnia 2026 r.. W przeciwnym razie zostanie im przydzielony poziom Społeczność. Limity poziomu zaczną obowiązywać we wszystkich projektach (niezależnie od daty wyboru poziomu) od
27 kwietnia 2026 r. Więcej informacji
ee.Number.expression
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Oblicza wyrażenie liczbowe.
| Wykorzystanie | Zwroty |
|---|
ee.Number.expression(expression, vars) | Liczba |
| Argument | Typ | Szczegóły |
|---|
expression | Ciąg znaków | Ciąg tekstowy wyrażenia matematycznego do obliczenia. Oprócz standardowych operatorów arytmetycznych, logicznych i relacyjnych wyrażenia obsługują też dowolną funkcję w obiekcie Number, operator „.” do wyodrębniania elementów podrzędnych ze słownika „vars” oraz stałe matematyczne Math.PI i Math.E. |
vars | Słownik, domyślny: null | Słownik nazwanych wartości, których można używać w wyrażeniu. |
Przykłady
Edytor kodu (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));
Konfiguracja Pythona
Informacje o interfejsie Python API i używaniu geemap do interaktywnego programowania znajdziesz na stronie
Środowisko 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))
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-10-30 UTC.
[null,null,["Ostatnia aktualizacja: 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"]]