ประกาศ : โปรเจ็กต์ที่ไม่ใช่เชิงพาณิชย์ทั้งหมดที่ลงทะเบียนเพื่อใช้ Earth Engine ก่อนวันที่
15 เมษายน 2025 ต้อง
ยืนยันการมีสิทธิ์ที่ไม่ใช่เชิงพาณิชย์ เพื่อรักษาสิทธิ์เข้าถึง หากคุณไม่ยืนยันภายในวันที่ 26 กันยายน 2025 ระบบอาจระงับสิทธิ์เข้าถึงของคุณ
ส่งความคิดเห็น
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.
print ( 'x + y:' ,
ee . Number . expression ( 'x + y' , variables ) . getInfo ())
print ( 'x - y:' ,
ee . Number . expression ( 'x - y' , variables ) . getInfo ())
print ( 'x * y:' ,
ee . Number . expression ( 'x * y' , variables ) . getInfo ())
print ( 'x / y:' ,
ee . Number . expression ( 'x / y' , variables ) . getInfo ())
print ( 'x ** y:' ,
ee . Number . expression ( 'x ** y' , variables ) . getInfo ())
print ( 'x % y:' ,
ee . Number . expression ( 'x % y' , variables ) . getInfo ())
# Logical operators.
print ( 'x || y:' ,
ee . Number . expression ( 'x || y' , variables ) . getInfo ())
print ( 'x && y:' ,
ee . Number . expression ( 'x && y' , variables ) . getInfo ())
print ( '!(x):' ,
ee . Number . expression ( '!(x)' , variables ) . getInfo ())
# Relational operators.
print ( 'x > y:' ,
ee . Number . expression ( 'x > y' , variables ) . getInfo ())
print ( 'x >= y:' ,
ee . Number . expression ( 'x >= y' , variables ) . getInfo ())
print ( 'x < y:' ,
ee . Number . expression ( 'x < y' , variables ) . getInfo ())
print ( 'x <= y:' ,
ee . Number . expression ( 'x <= y' , variables ) . getInfo ())
print ( 'x == y:' ,
ee . Number . expression ( 'x == y' , variables ) . getInfo ())
print ( 'x != y:' ,
ee . Number . expression ( 'x != y' , variables ) . getInfo ())
# Conditional JavaScript (ternary) operator.
print ( '(x < y) ? 100 : 1000):' ,
ee . Number . expression ( '(x < y) ? 100 : 1000' , variables ) . getInfo ())
# Constants in the expression.
print ( '100 * (x + y):' ,
ee . Number . expression ( '100 * (x + y)' , variables ) . getInfo ())
# JavaScript Math constants.
print ( 'Math.PI:' ,
ee . Number . expression ( 'Math.PI' , None ) . getInfo ())
print ( 'Math.E:' ,
ee . Number . expression ( 'Math.E' , None ) . getInfo ())
# 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 }) . getInfo ())
# ee.Number functions.
print ( 'Use ee.Number add. add(x, y):' ,
ee . Number . expression ( 'add(x, y)' , variables ) . getInfo ())
print ( 'Use ee.Number add and subtract. subtract(add(x, y), 5):' ,
ee . Number . expression ( 'subtract(add(x, y), 5)' , variables ) . getInfo ())
ส่งความคิดเห็น
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-29 UTC
หากต้องการบอกให้เราทราบเพิ่มเติม
[[["เข้าใจง่าย","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-07-29 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"]]