toDictionary#
- geetools.FeatureCollectionAccessor.toDictionary(keyColumn='system:index', selectors=None)#
Convert to Dictionary.
- Parameters:
- Return type:
a
ee.Dictionarywith values of keyColumn as keys andee.Dictionaryas values. The output will look like
Examples
import ee, geetools from geetools.utils import initialize_documentation import json initialize_documentation() # Extracting the first 3 countries from the FAO GAUL dataset. # and transform them into dictionary countries = ( ee.FeatureCollection("FAO/GAUL/2015/level0") .select(["ADM0_NAME", "ADM0_CODE"]) .limit(3) .geetools.toDictionary() ) print(json.dumps(countries.getInfo(), indent=2))
{ "00000000000000000003": { "ADM0_CODE": 2647, "ADM0_NAME": "Montenegro", "system:index": "00000000000000000003" }, "0000000000000000000c": { "ADM0_CODE": 2648, "ADM0_NAME": "Serbia", "system:index": "0000000000000000000c" }, "0000000000000000002e": { "ADM0_CODE": 74, "ADM0_NAME": "South Sudan", "system:index": "0000000000000000002e" } }