Announcement: All noncommercial projects registered to use Earth Engine beforeApril 15, 2025 mustverify noncommercial eligibility to maintain access. If you have not verified by September 26, 2025, your access may be on hold.

ee.List.frequency

  • TheList.frequency function returns the number of times a specific element appears in a list.

  • It takes the list and the element to count as arguments.

  • The function returns an integer representing the frequency of the element.

  • Examples show how to useList.frequency in both JavaScript and Python.

Returns the number of elements in list equal to element.

UsageReturns
List.frequency(element)Integer
ArgumentTypeDetails
this:listList
elementObject

Examples

Code Editor (JavaScript)

// An ee.Image list object.varlist=ee.List([0,1,2,2,3,4]);print('List of integers',list);// The ee.List.frequency function is used to determine how many times a value is// present in a list, e.g. what is the frequency of 0, 2, and 9 in the list.print('Frequency of value 0',list.frequency(0));print('Frequency of value 2',list.frequency(2));print('Frequency of value 9',list.frequency(9));

Python setup

See the Python Environment page for information on the Python API and usinggeemap for interactive development.

importeeimportgeemap.coreasgeemap

Colab (Python)

# An ee.Image list object.ee_list=ee.List([0,1,2,2,3,4])display('List of integer:',ee_list)# The ee.List.frequency function is used to determine how many times a value is# present in a list, e.g. what is the frequency of 0, 2, and 9 in the list.display('Frequency of value 0:',ee_list.frequency(0))display('Frequency of value 2:',ee_list.frequency(2))display('Frequency of value 9:',ee_list.frequency(9))

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2023-10-06 UTC.