Announcement: On November 13, 2024, all users will need to use a Cloud project in order to access Earth Engine. After this date, continued individual access without a Cloud project will require an exception.
Stay organized with collections
Save and categorize content based on your preferences.
Apply a reducer to an array by collapsing all the input values along each specified axis into a single output value computed by the reducer.
The output always has the same dimensionality as the input, and the individual axes are affected as follows:
The axes specified in the 'axes' parameter have their length reduced to 1 (by applying the reducer).
If the reducer has multiple inputs or multiple outputs, the axis specified in 'fieldAxis' will be used to provide the reducer's inputs and store the reducer's outputs.
All other axes are unaffected (independent reductions are performed).
Usage
Returns
Array.reduce(reducer, axes, fieldAxis)
Array
Argument
Type
Details
this: array
Array
The array.
reducer
Reducer
The reducer to apply. Each of its outputs must be a number, not an array or other type.
axes
List
The list of axes over which to reduce. The output will have a length of 1 in all these axes.
fieldAxis
Integer, default: null
The axis to use as the reducer's input and output fields. Only required if the reducer has multiple inputs or multiple outputs, in which case the axis must have length equal to the number of reducer inputs, and in the result it will have length equal to the number of reducer outputs.
[[["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 2024-07-13 UTC."],[[["`Array.reduce` collapses input values along specified axes into single output values using a provided reducer function."],["Output dimensions match input dimensions, with reduced axes having length 1 and unaffected axes remaining unchanged."],["For reducers with multiple inputs/outputs, the `fieldAxis` parameter manages data flow."],["The reducer function must produce numerical outputs, not arrays or other types."]]],[]]