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 API 和如何使用 geemap 进行交互式开发,请参阅 Python 环境页面。

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())