<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to statistic vector area from a local featureLayer in Kotlin SDK in Kotlin Maps SDK Questions</title>
    <link>https://community.esri.com/t5/kotlin-maps-sdk-questions/how-to-statistic-vector-area-from-a-local/m-p/1653696#M597</link>
    <description>&lt;P&gt;&lt;SPAN&gt;I am developing an Android application using the ArcGIS Maps SDK for Kotlin (version 200.6).I'm currently using&amp;nbsp;StatisticsQueryParameters to perform statistics on other attribute fields in the FeatureTable, and it works well. Now I need to&amp;nbsp;statistic vector area.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="kotlin"&gt;        val statisticDefinition = StatisticDefinition(
            areaFieldName, metricFieldStatisticType, areaFieldAlias
        )

        statisticDefinitions.add(statisticDefinition)
        
        val queryParameters = StatisticsQueryParameters(statisticDefinitions).apply {

            groupByFieldNames.add(firstLevelGroupByFieldName)
            
            secondLevelGroupByFieldName?.let {
                groupByFieldNames.add(it)
            }
            
            boundary?.let {
                geometry = it
            }

        }

        featureTable.queryStatistics(queryParameters).onSuccess { statisticsQueryResult -&amp;gt;
            statisticsQueryResult.forEach { statisticRecord -&amp;gt;

                val groupMap = statisticRecord.group
                val statisticsMap = statisticRecord.statistics

                val tableQueryByLevelRow = TableQueryRow.TableQueryByLevelRow(
                    firstLevelValue = groupMap[firstLevelGroupByFieldName].toString(),
                    secondLevelValue = groupMap[secondLevelGroupByFieldName]?.toString(),
                    metricFieldValue = formatStatisticValue(statisticsMap[areaFieldAlias])?:"",
                )

                result.add(tableQueryByLevelRow)

            }
        }.onFailure { e -&amp;gt;
            throw e
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;SPAN&gt;I know how to statistic the total area by iterating through each feature, getting its geometry, and summing areas.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;Is there a better or more efficient method to statistic vector area?&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 28 Sep 2025 00:49:31 GMT</pubDate>
    <dc:creator>LiqiangZhu</dc:creator>
    <dc:date>2025-09-28T00:49:31Z</dc:date>
    <item>
      <title>How to statistic vector area from a local featureLayer in Kotlin SDK</title>
      <link>https://community.esri.com/t5/kotlin-maps-sdk-questions/how-to-statistic-vector-area-from-a-local/m-p/1653696#M597</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I am developing an Android application using the ArcGIS Maps SDK for Kotlin (version 200.6).I'm currently using&amp;nbsp;StatisticsQueryParameters to perform statistics on other attribute fields in the FeatureTable, and it works well. Now I need to&amp;nbsp;statistic vector area.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="kotlin"&gt;        val statisticDefinition = StatisticDefinition(
            areaFieldName, metricFieldStatisticType, areaFieldAlias
        )

        statisticDefinitions.add(statisticDefinition)
        
        val queryParameters = StatisticsQueryParameters(statisticDefinitions).apply {

            groupByFieldNames.add(firstLevelGroupByFieldName)
            
            secondLevelGroupByFieldName?.let {
                groupByFieldNames.add(it)
            }
            
            boundary?.let {
                geometry = it
            }

        }

        featureTable.queryStatistics(queryParameters).onSuccess { statisticsQueryResult -&amp;gt;
            statisticsQueryResult.forEach { statisticRecord -&amp;gt;

                val groupMap = statisticRecord.group
                val statisticsMap = statisticRecord.statistics

                val tableQueryByLevelRow = TableQueryRow.TableQueryByLevelRow(
                    firstLevelValue = groupMap[firstLevelGroupByFieldName].toString(),
                    secondLevelValue = groupMap[secondLevelGroupByFieldName]?.toString(),
                    metricFieldValue = formatStatisticValue(statisticsMap[areaFieldAlias])?:"",
                )

                result.add(tableQueryByLevelRow)

            }
        }.onFailure { e -&amp;gt;
            throw e
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;SPAN&gt;I know how to statistic the total area by iterating through each feature, getting its geometry, and summing areas.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;Is there a better or more efficient method to statistic vector area?&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Sep 2025 00:49:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/kotlin-maps-sdk-questions/how-to-statistic-vector-area-from-a-local/m-p/1653696#M597</guid>
      <dc:creator>LiqiangZhu</dc:creator>
      <dc:date>2025-09-28T00:49:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to statistic vector area from a local featureLayer in Kotlin SDK</title>
      <link>https://community.esri.com/t5/kotlin-maps-sdk-questions/how-to-statistic-vector-area-from-a-local/m-p/1656832#M601</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;BR /&gt;If you have enabled &lt;EM&gt;&lt;STRONG&gt;Shape_Area&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;field on your feature layer, then you can use it as the attribute to perform the statistics query on it to compute the SUM/Average etc.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Rama&lt;/P&gt;</description>
      <pubDate>Thu, 09 Oct 2025 19:23:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/kotlin-maps-sdk-questions/how-to-statistic-vector-area-from-a-local/m-p/1656832#M601</guid>
      <dc:creator>RamaChintapalli</dc:creator>
      <dc:date>2025-10-09T19:23:56Z</dc:date>
    </item>
  </channel>
</rss>

