ee.Dictionary.keys
Retrieve the keys of a dictionary as a list. The keys will be sorted in natural order.
Usage | Returns |
---|
Dictionary.keys() | List |
Argument | Type | Details |
---|
this: dictionary | Dictionary | |
Examples
// A dictionary (e.g. results of ee.Image.reduceRegion of an S2 image).
var dict = ee.Dictionary({
B1: 182,
B2: 219,
B3: 443
});
print('The list of dictionary keys', dict.keys());
Python setup
See the
Python Environment page for information on the Python API and using
geemap
for interactive development.
import ee
import geemap.core as geemap
# A dictionary (e.g. results of ee.Image.reduceRegion of an S2 image).
dic = ee.Dictionary({
'B1': 182,
'B2': 219,
'B3': 443
})
print('The list of dictionary keys:', dic.keys().getInfo())
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-13 UTC.
[null,null,["Last updated 2024-07-13 UTC."],[[["`Dictionary.keys()` retrieves all keys from a given dictionary and returns them as a list sorted in natural order."],["This function is applicable to dictionaries in both JavaScript and Python environments within the Earth Engine context."],["The returned list can be printed or used in further operations within your Earth Engine scripts."]]],["The `keys()` method retrieves a dictionary's keys as a list, sorted in natural order. It requires a dictionary as input (`this: dictionary`). The output is a list of the keys. Examples in JavaScript and Python show creating a dictionary and then using `keys()` to extract the keys, demonstrating the use of the method in different programming environments.\n"]]