コールバック関数が指定されていない場合、リクエストは同期的に行われます。コールバックが指定されている場合、リクエストは非同期で行われます。
同期モードではサーバーを待機している間、他のすべてのコード(EE コードエディタの UI など)が停止するため、非同期モードが推奨されます。非同期リクエストを行う場合は、getInfo() よりも evaluate() を使用することをおすすめします。
このオブジェクトの計算値を返します。
用途 | 戻り値 |
---|---|
String.getInfo(callback) | オブジェクト |
引数 | タイプ | 詳細 |
---|---|---|
これ: computedobject | ComputedObject | 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
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