Announcement: All noncommercial projects registered to use Earth Engine before April 15, 2025 must verify noncommercial eligibility to maintain Earth Engine access.
Stay organized with collections
Save and categorize content based on your preferences.
Returns the position, as a list of indices in each array axis, of the maximum value in an array, or null if the array is empty. If there are multiple occurrences of the maximum, returns the position of the first.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-10-06 UTC."],[[["\u003cp\u003e\u003ccode\u003eArray.argmax()\u003c/code\u003e returns the position of the maximum value within an array as a list of indices.\u003c/p\u003e\n"],["\u003cp\u003eIf multiple maximum values exist, the function returns the position of the first occurrence.\u003c/p\u003e\n"],["\u003cp\u003eAn empty array input results in a \u003ccode\u003enull\u003c/code\u003e (JavaScript) or \u003ccode\u003eNone\u003c/code\u003e (Python) output.\u003c/p\u003e\n"],["\u003cp\u003eThe function operates across all dimensions of the input array.\u003c/p\u003e\n"]]],["The `argmax()` function finds the position of the maximum value within an array. It returns a list of indices, representing the location in each array dimension. If the array is empty, it returns null. In cases of multiple maximum values, it returns the index of the first occurrence. Usage is `Array.argmax()`, and it takes one array argument. Examples illustrate its behavior with empty, single-value, multi-value, and multi-dimensional arrays.\n"],null,["Returns the position, as a list of indices in each array axis, of the maximum value in an array, or null if the array is empty. If there are multiple occurrences of the maximum, returns the position of the first.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|------------------|---------|\n| Array.argmax`()` | List |\n\n| Argument | Type | Details |\n|---------------|-------|---------|\n| this: `array` | Array | |\n\nExamples\n\nCode Editor (JavaScript) \n\n```javascript\n// Return the position of the maximum value in each dimension.\n\n// Returns null if the array is empty.\nprint(ee.Array([], ee.PixelType.int8()).argmax()); // null\n\nprint(ee.Array([9]).argmax()); // [0]\nprint(ee.Array([0, -1, 2, 1]).argmax()); // [2]\nprint(ee.Array([[3, 4, 2], [6, 5, 7]]).argmax()); // [1, 2]\n\n// Returns the first occurrence of the maximum.\nprint(ee.Array([1, 1, 1, 9, 9, 9]).argmax()); // [3]\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\nColab (Python) \n\n```python\n# Return the position of the maximum value in each dimension.\n\n# Returns null if the array is empty.\ndisplay(ee.Array([], ee.PixelType.int8()).argmax()) # None\n\ndisplay(ee.Array([9]).argmax()) # [0]\ndisplay(ee.Array([0, -1, 2, 1]).argmax()) # [2]\ndisplay(ee.Array([[3, 4, 2], [6, 5, 7]]).argmax()) # [1, 2]\n\n# Returns the first occurrence of the maximum.\ndisplay(ee.Array([1, 1, 1, 9, 9, 9]).argmax()) # [3]\n```"]]