当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


JavaScript ArcGIS StatisticDefinition用法及代码示例


基本信息

以下是所在类或对象的基本信息。

AMD: require(["esri/tasks/support/StatisticDefinition"], (StatisticDefinition) => { /* code goes here */ });

ESM: import StatisticDefinition from "@arcgis/core/tasks/support/StatisticDefinition";

类: esri/tasks/support/StatisticDefinition

继承: StatisticDefinition > Accessor

自从:用于 JavaScript 4.0 的 ArcGIS API

用法说明

已弃用 从 4.20 版开始。请改用StatisticDefinition

此类定义用于查询图层或图层视图以获取统计信息的参数。

例子:

// query for the sum of the population in all features
let sumPopulation = {
  onStatisticField: "POP_2015",  // service field for 2015 population
  outStatisticFieldName: "Pop_2015_sum",
  statisticType: "sum"
}
let query = layer.createQuery();
query.outStatistics = [ sumPopulation ];
layer.queryFeatures(query)
  .then(function(response){
     let stats = response.features[0].attributes;
     console.log("output stats:", stats);
  });
// query for the average of the population change for all features
let populationChangeDefinition = {
  onStatisticField: "POP_2015 - POP_2010",  // service field for 2015 population
  outStatisticFieldName: "avg_pop_change_2015_2010",
  statisticType: "avg"
}
let query = layer.createQuery();
query.outStatistics = [ populationChangeDefinition ];
layer.queryFeatures(query)
  .then(function(response){
     let stats = response.features[0].attributes;
     console.log("Average change:", stats.avg_pop_change_2015_2010);
  });

相关用法


注:本文由纯净天空筛选整理自arcgis.com大神的英文原创作品 StatisticDefinition。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。