I am developing an Android application using the ArcGIS Maps SDK for Kotlin (version 200.6).I'm currently using StatisticsQueryParameters to perform statistics on other attribute fields in the FeatureTable, and it works well. Now I need to statistic vector area.
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 ->
statisticsQueryResult.forEach { statisticRecord ->
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 ->
throw e
}I know how to statistic the total area by iterating through each feature, getting its geometry, and summing areas.
Is there a better or more efficient method to statistic vector area?
Hi,
If you have enabled Shape_Area 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.
Thanks
Rama