當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。