byFeatures#

geetools.FeatureCollectionAccessor.byFeatures(featureId='system:index', properties=None, labels=None)#

Get a dictionary with all property values for each feature.

This method is returning a dictionary with all the feature ids as keys and their properties as a dictionary.

{
    "feature1": {"property1": value1, "property2": value2, ...},
    "feature2": {"property1": value1, "property2": value2, ...},
    ...
}

The output remain server side and can be used to create a client side plot.

Parameters:
  • featureId (str | ee.String) – The property to use as the feature id. Defaults to "system:index". This property needs to be a string property.

  • properties (list[str] | ee.List | None) – A list of properties to get the values from. By default, all properties will be used.

  • labels (list[str] | ee.List | None) – A list of names to replace properties names. Default to the properties names.

Returns:

A dictionary with all the feature ids as keys and their properties as a dictionary.

Return type:

ee.Dictionary

See also

  • byProperties: Get a dictionary with all feature values for each property.

  • plot_by_features: Plot the values of a :py:class:`ee.FeatureCollection` by feature.

Examples

import ee, geetools
from geetools.utils import initialize_documentation
from matplotlib import pyplot as plt

initialize_documentation()

fc = ee.FeatureCollection("FAO/GAUL/2015/level2").limit(3)
d = fc.geetools.byFeatures(properties=["ADM0_CODE", "ADM1_CODE", "ADM2_CODE"])
d.getInfo()
{'00000000000000000253': {'ADM0_CODE': 257,
  'ADM1_CODE': 48357,
  'ADM2_CODE': 115068},
 '00000000000000000267': {'ADM0_CODE': 257,
  'ADM1_CODE': 115003,
  'ADM2_CODE': 115032},
 '00000000000000000269': {'ADM0_CODE': 257,
  'ADM1_CODE': 115003,
  'ADM2_CODE': 115069}}