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


JavaScript ArcGIS Graphic.aggregateGeometries用法及代码示例


基本信息

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

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

ESM: import Graphic from "@arcgis/core/Graphic";

类: esri/Graphic

继承: Graphic > Accessor

自从:用于 JavaScript 4.0 的 ArcGIS API

用法说明

Graphic.aggregateGeometries函数(或属性)的定义如下:

aggregateGeometries Object


自从:ArcGIS 适用于 JavaScript 4.23 的 API

当使用 envelope-aggregatecentroid-aggregate 和/或 convex-hull-aggregate 统计类型执行 statistics 查询时,aggregateGeometries 包含空间聚合几何。 aggregateGeometries 上的每个属性都填充有statistics field,其中包含与聚合统计类型匹配的聚合几何。

例子:

// average of age fields by regions
const ageStatsByRegion = new StatisticDefinition({
  onStatisticField: field,
  outStatisticFieldName: "avgAge",
  statisticType: "avg"
});

// extent encompassing all features by region
const aggregatedExtent = new StatisticDefinition({
  statisticType: "envelope-aggregate",
  outStatisticFieldName: "aggregateExtent",
});

// group the statistics by Region field
// get avg age by Regions and extent of each region
const query = layer.createQuery();
query.groupByFieldsForStatistics = ["Region"];
query.outStatistics = [consumeStatsByRegion, aggregatedExtent];
layer.queryFeatures(query).then((results) => {
  results.features.forEach((feature) => {
    if (feature.attributes.Region === "Midwest") {
       view.goTo(feature.aggregateGeometries.aggregateExtent);
    }
  });
});

相关用法


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