ee.ImageCollection.set

覆寫一或多個 Element 的中繼資料屬性。

傳回覆寫指定屬性的元素。

用量傳回
ImageCollection.set(var_args)元素
引數類型詳細資料
這個:element元素Element 執行個體。
var_argsVarArgs<Object>屬性字典或屬性的 vararg 序列,例如 key1、value1、key2、value2 等。

範例

程式碼編輯器 (JavaScript)

// A contrived, empty image collection for simple demonstration.
var col = ee.ImageCollection([]);
print('Collection without properties', col);

// Set collection properties using a dictionary.
col = col.set({
  project_name: 'biomass_tracking',
  project_id: 3,
  plot_ids: ee.Array([7, 11, 20])
});

// Set collection properties using a series of key-value pairs.
col = col.set('project_year', 2018,
              'rgb_vis', 'false_color');

print('Collection with properties', col);

// Get a dictionary of collection property keys and values.
print('Property keys and values (ee.Dictionary)', col.toDictionary());

// Get the value of a collection property. To use the result of
// ee.ImageCollection.get in further computation, you need to cast it to the
// appropriate class, for example, ee.Number(result) or ee.String(result).
print('Project ID (ambiguous object)', col.get('project_id'));

// Get the value of a string collection property as an ee.String object.
print('Project name (ee.String)', col.getString('project_name'));

// Get the value of a numeric collection property as an ee.Number object.
print('Project year (ee.Number)', col.getNumber('project_year'));

// Get the value of an ee.Array collection property as an ee.Array object.
print('Plot IDs (ee.Array)', col.getArray('plot_ids'));

Python 設定

請參閱 Python 環境頁面,瞭解 Python API 和如何使用 geemap 進行互動式開發。

import ee
import geemap.core as geemap

Colab (Python)

# A contrived, empty image collection for simple demonstration.
col = ee.ImageCollection([])
print('Collection without properties:', col.getInfo())

# Set collection properties using a dictionary.
col = col.set({
    'project_name': 'biomass_tracking',
    'project_id': 3,
    'plot_ids': ee.Array([7, 11, 20])
})

# Set collection properties using a series of key-value pairs.
col = col.set('project_year', 2018,
              'rgb_vis', 'false_color')

print('Collection with properties:', col.getInfo())

# Get a dictionary of collection property keys and values.
print('Property keys and values (ee.Dictionary):', col.toDictionary().getInfo())

# Get the value of a collection property. To use the result of
# ee.ImageCollection.get in further computation, you need to cast it to the
# appropriate class, for example, ee.Number(result) or ee.String(result).
print('Project ID (ambiguous object):', col.get('project_id').getInfo())

# Get the value of a string collection property as an ee.String object.
print('Project name (ee.String):', col.getString('project_name').getInfo())

# Get the value of a numeric collection property as an ee.Number object.
print('Project year (ee.Number):', col.getNumber('project_year').getInfo())

# Get the value of an ee.Array collection property as an ee.Array object.
print('Plot IDs (ee.Array):', col.getArray('plot_ids').getInfo())