ERROR

The spatial index grid size is invalid

Last Published: April 25, 2020

Error Message

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.

Cause

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

Article ID:000010090

Software:
  • ArcMap

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic