ee.Dictionary.remove

傳回已移除指定鍵的字典。

用量傳回
Dictionary.remove(selectors, ignoreMissing)字典
引數類型詳細資料
這個:dictionary字典
selectors清單要移除的金鑰名稱清單或金鑰名稱規則運算式。
ignoreMissing布林值,預設值為 false忽略與至少 1 個鍵不符的選取器。

範例

程式碼編輯器 (JavaScript)

// A dictionary (e.g. results of ee.Image.reduceRegion of an S2 image).
var dict = ee.Dictionary({
  B1: 182,
  B2: 219,
  B3: 443
});

print('Dictionary with selected keys removed', dict.remove(['B2', 'B3']));

print('Set ignoreMissing as true to avoid an unmatched key error',
      dict.remove({selectors: ['B2', 'B3', 'Region'], ignoreMissing: true}));

Python 設定

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

import ee
import geemap.core as geemap

Colab (Python)

# A dictionary (e.g. results of ee.Image.reduceRegion of an S2 image).
dic = ee.Dictionary({
    'B1': 182,
    'B2': 219,
    'B3': 443
})

print('Dictionary with selected keys removed:',
      dic.remove(['B2', 'B3']).getInfo())

dic_subset = dic.remove(**{'selectors': ['B2', 'B3', 'Region'],
                          'ignoreMissing': True})
print('Set ignoreMissing as true to avoid an unmatched key error:',
      dic_subset.getInfo())