CalculateStatistics on a selectionset

408
2
08-03-2018 04:56 PM
AndreaSmith1
New Contributor

I'm doing a spatial query to retrieve the number of points that are contained within a selected polygon. Using that selection set I need to run statistics on a number of fields to return the mean values. How do I convert that selectionset returned from layer.Select(SpatialQuery) to a featureclass so I can then run the CalculateStatistics function?

0 Kudos
2 Replies
RichRuh
Esri Regular Contributor

Hi Andrea,

There is no direct way to do this.  The best solution at this point is to create a temporary table from your selection using geoprocessing tools and use that to run Table.CalculateStatistics().

--Rich

0 Kudos
RichRuh
Esri Regular Contributor

While there is no direct way to call CalculateStatistics on a Selection object, you might be able to do what you want for this particular instance.

Instead of calling Layer.Select(yourSpatialQuery), you can get the underlying Table from the layer (e.g., BasicFeatureLayer.GetTable()).  Then you could call Table.CalculateStatistics() on that underlying table, setting TableStatisticsDescription.QueryFilter equal to yourSpatialQuery.

--Rich

0 Kudos