Select to view content in your preferred language

Statistics Filtered By Geometry

2438
3
Jump to solution
10-01-2012 04:53 PM
DanBeatty
Deactivated User
I am trying to calculate statistics for a feature layer. I can get the statistics for the entire layer using the sample code as a guide no problem. My question is can I filter the query based on a geometry and calculate statistics on that result. I need to be able to calculate statistics on the spatially selected subset of the feature layer. When I add the query.Geometry=SomeGeometry to the query of the querytask i get no results. Is this even possible, if so how?


Private Sub OutStatisticsDataGrid_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim query As New Query()
With query

.geometry = SomeGeometry

.GroupByFieldsForStatistics = New List(Of String) _
From {"SUB_REGION"}
.OutStatistics = New List(Of OutStatistic) _
From
{New OutStatistic() With
{
.OnStatisticField = "pop2000",
.OutStatisticFieldName = "SubRegionPopulation",
.StatisticType = StatisticType.Sum
},
New OutStatistic() With
{
.OnStatisticField = "sub_region",
.OutStatisticFieldName = "NumberOfStates",
.StatisticType = StatisticType.Count
}
}
End With
queryTask.ExecuteAsync(query)
End Sub

Thanks!

Dan
0 Kudos
1 Solution

Accepted Solutions
PeterYurkosky1
Regular Contributor
A statistics query will not work with a spatial filter in ArcGIS Server 10.1. We've added this function to the map service at 10.1 service pack 1. See the service pack announcement here. The bug number is NIM083547.

View solution in original post

0 Kudos
3 Replies
DominiqueBroux
Esri Frequent Contributor
Is your issue due to the statistics or to your geometry?

In others words, if you make a simple spatial query with your geometry as filter and without any statistics, does your query return any features?
0 Kudos
PeterYurkosky1
Regular Contributor
A statistics query will not work with a spatial filter in ArcGIS Server 10.1. We've added this function to the map service at 10.1 service pack 1. See the service pack announcement here. The bug number is NIM083547.
0 Kudos
DanBeatty
Deactivated User
To answer the first question, yes if I don't return statistics the spatial filter does work. Thanks for the update glad to see this addressed in sp1.
0 Kudos