HOW TO
Instructions provided describe how to use ArcObjects to calculate the recommended spatial index size for a feature class.
Note: For more information on creating a UIControl, see the ArcGIS Desktop Help topic: 'Creating custom commands with VBA and UI Controls'
Code: Dim pGxApp As IGxApplication Dim pGxDataset As IGxDataset Dim pDataset As IDataset Dim pFClass As IFeatureClass Dim pFCursor As IFeatureCursor Dim pFeature As IFeature Dim dblTotal As Double Dim iFCount As Integer Set pGxApp = Application If pGxApp.SelectedObject Is Nothing Then MsgBox "Select FeatureClass" Exit Sub End If If Not TypeOf pGxApp.SelectedObject Is IGxDataset Then MsgBox "Select FeatureClass" Exit Sub End If Set pGxDataset = pGxApp.SelectedObject Set pDataset = pGxDataset.Dataset Set pFClass = pDataset If pFClass.ShapeType = esriGeometryPoint Then MsgBox "Select Line or Polygon FeatureClass" Exit Sub End If Set pFCursor = pFClass.Search(Nothing, False) Set pFeature = pFCursor.NextFeature dblTotal = 0 iFCount = 1 Do Until pFeature Is Nothing dblTotal = dblTotal + ((pFeature.Extent.Height + pFeature.Extent.Width) / 2) Set pFeature = pFCursor.NextFeature iFCount = iFCount + 1 Loop MsgBox "Recommended Spatial Index: " & Round(((dblTotal / iFCount) * 3), 2)
Get help from ArcGIS experts
Download the Esri Support App