ee.String.getInfo

אחזור הערך של האובייקט הזה מהשרת.

אם לא מספקים פונקציית קריאה חוזרת, הבקשה מתבצעת באופן סינכרוני. אם מציינים קריאה חוזרת (callback), הבקשה מתבצעת באופן אסינכרוני.

מומלץ להשתמש במצב אסינכרוני כי במצב סינכרוני כל הקוד האחר (לדוגמה, ממשק המשתמש של עורך הקוד של EE) מושהה בזמן ההמתנה לשרת. כדי לשלוח בקשה לא סנכרונית, עדיף להשתמש בפונקציה evaluate() במקום בפונקציה getInfo().

מחזירה את הערך המחושב של האובייקט הזה.

שימושהחזרות
String.getInfo(callback)אובייקט
ארגומנטסוגפרטים
זה: computedobjectComputedObjectהמופע של ComputedObject.
callbackפונקציה, אופציונליקריאה חוזרת אופציונלית. אם לא מספקים את הערך הזה, השיחה מתבצעת באופן סינכרוני.

דוגמאות

עורך הקוד (JavaScript)

// After getInfo(), the instance is a local JavaScript string.
// Regular JavaScript string manipulations are then available.
//
// Note: getInfo() fetches results from Earth Engine immediately, and may freeze
// the browser or lead to poor performance.  Use evaluate() to avoid this.

print(ee.String('abc').getInfo().charAt(1));  // b
print(ee.String('abc').getInfo()[2]);         // c

// Using + with ee.String has unexpected results
print(ee.String('abc') + 'def');  // ee.String("abc")def

// Fetch string using getInfo
print(ee.String('abc').getInfo() + 'def');  // abcdef

// Improved solution: cat is available on ee.String
print(ee.String('abc').cat('def'));  // abcdef

הגדרת Python

מידע על Python API ועל שימוש ב-geemap לפיתוח אינטראקטיבי מופיע בדף Python Environment.

import ee
import geemap.core as geemap

Colab (Python)

# After getInfo(), the instance is a local Python string.
# Regular Python string manipulations are then available.

# Note: getInfo() fetches results from Earth Engine synchronously;
# later expressions will not be evaluated until it completes.

print(ee.String('abc').getInfo()[-2])  # b
print(ee.String('abc').getInfo()[2])  # c

# Fetch string using getInfo
print(ee.String('abc').getInfo() + 'def')  # abcdef