summaryStatistics
require(["esri/renderers/smartMapping/statistics/summaryStatistics"], function(summaryStatistics) { /* code goes here */ });
esri/renderers/smartMapping/statistics/summaryStatistics
Function for generating attribute statistics in a Layer based on values returned from a given field.
Known Limitations
- Only FeatureLayer, SceneLayer, CSVLayer, and PointCloudLayer layer types are currently supported, except in the following scenarios:
- SceneLayers without the
supportsRenderer
andsupportsLayerQuery
capabilities enabled, unless a predefined statistics object is passed to thestatistics
parameter of the method in conjunction with the layer. To check a SceneLayer's capabilities, use the getFieldInfoUsage() method.
- SceneLayers without the
- You cannot generate statistics using SQL expressions for client-side FeatureLayers in a SceneView.
Method Overview
Name | Return Type | Summary | Function | |
---|---|---|---|---|
Promise<SummaryStatisticsResult> | Returns an object containing various statistics describing a set of values returned from a field (or expression) in a Layer. more details | more details | summaryStatistics |
Method Details
- summaryStatistics(params){Promise<SummaryStatisticsResult>}
Returns an object containing various statistics describing a set of values returned from a field (or expression) in a Layer.
Parameters:params ObjectSee the table below for details of each parameter.
Specification:The layer from which to generate statistics for the given
field
.field StringoptionalThe name of the numeric field for which the summary statistics will be generated. This property is ignored if a
valueExpression
is used.valueExpression StringoptionalAn Arcade expression that returns a number. This expression can reference field values using the
$feature
global variable. This property overrides thefield
property and therefore is used instead of an inputfield
value.sqlExpression StringoptionalA SQL expression evaluating to a number.
sqlWhere StringoptionalA SQL where clause used to filter features for the statistics query. For example, this is useful in situations where you want to avoid dividing by zero as is the case with creating a predominance visualization.
normalizationField StringoptionalThe field by which to normalize the values returned from the given
field
.minValue NumberoptionalThe minimum bounding value for the statistics calculation. Use this in conjunction with
maxValue
to generate statistics between lower and upper bounds.maxValue NumberoptionalThe maximum bounding value for the statistics calculation. Use this in conjunction with
minValue
to generate statistics between lower and upper bounds.view ViewoptionalA SceneView or MapView instance is required when a
valueExpression
is specified.features Graphic[]optionalA subset of features for which to calculate the statistics.
Returns:Type Description Promise<SummaryStatisticsResult> Returns a promise that resolves to SummaryStatisticsResult. Example:summaryStatistics({ layer: featureLayer, valueExpression: "( ($feature.POP2020 - $feature.POP2010) / $feature.POP2010 ) * 100" view: mapView }).then(function(stats){ colorSlider.statistics = stats; });
Type Definitions
- SummaryStatisticsResult
The statistics returned from the summaryStatistics() query.
- Properties:
- avg Number
The average of all values returned from the field or expression.
count NumberThe number of features evaluated.
max NumberThe maximum of all values returned from the field or expression.
min NumberThe minimum of all values returned from the field or expression.
stddev NumberThe standard deviation calculated from values returned from the field or expression.
sum NumberThe sum of all values returned from the field or expression.
variance NumberThe calculated variance from all values returned from the field or expression.