Error: The spatial index grid size is invalid
Note: This article pertains to ArcGIS versions 9.x. Later versions of ArcGIS may contain different functionality, as well as different names and locations for menus, commands and geoprocessing tools.
When creating a new feature through either the CreateFeature and Store method, or the use of an InsertCursor, the creation fails with the following error:
FDO_E_INVALID_GRID_SIZE -2147216894 The spatial index grid size is invalid.
The FDO_E_INVALID_GRID_SIZE error is raised because the grid size of the feature class where the feature is created is too small to manage the feature. This error only occurs with File or ArcSDE Geodatabases.
Solution or Workaround
Depending on when the error message is raised, there are two ways to manage it.
- If this error is encountered while editing in ArcMap, recalculate or modify the grid size of the feature class to accommodate the new feature. The recalculation of the grid size must be done from the Feature Class properties dialog box in ArcCatalog. This requires the use of the Stop Editing function. Save any edits, and close the Map Document containing the feature class. For steps to recalculate or modify the grid size of a feature class, refer to ArcMap: Rebuild a spatial index.
- If this error is encountered programmatically through the ArcObjects API, notifying the user to manually modify the spatial index is not ideal. Instead, prevent this error by placing the feature class in LoadOnly mode before inserting the feature. When the feature class is taken out of LoadOnly mode, the Geodatabase automatically recalculates an appropriate grid size. The following code demonstrates the use of the LoadOnly mode with a feature class:
'Place the feature class in loadonly mode. This step must be done before calling IFeature.Store or IFeatureCuror.InsertCursor Dim pFCLoad As IFeatureClassLoad Set pFCLoad = pFeatureClass pFCLoad.LoadOnlyMode = True 'Create feature buffer Dim pFeatBuffer As IFeatureBuffer Set pFeatBuffer = pFeatureClass.CreateFeatureBuffer Set pFeatBuffer.Shape = pGeometry 'Create insert cursor and insert buffer Dim pCursor As IFeatureCursor Set pCursor = pFeatureClass.Insert(True) 'Insert the feature and call flush pCursor.InsertFeature pFeatBuffer pCursor.Flush 'Take the feature class out of loadonly mode, and the Geodatabase calculates an appropriate grid size based on the features in the feature class pFCLoad.LoadOnlyMode = False
Last Published: 4/15/2020
Article ID: 000010090
Software: ArcMap 10.8, 10.7.1, 10.7, 10.6.1, 10.6, 10.5.1, 10.5, 10.4.1, 10.4, 10.3.1, 10.3, 10.2.2, 10.2.1, 10.2, 10.1, 10