The spatial index
Grid size is invalid Original Name lead to: http://www.cnblogs.com/linhugh/archive/2012/07/24/2606439.html
When SHP data was previously imported into Geodatabase, the program run with the error message "the spatial index grid size is invalid ".
Later, I checked ESRI and found the cause. It is a loadonlymode problem. Write it down and study it later.
Http://support.esri.com/en/knowledgebase/techarticles/detail/35007
Error: the spatial index grid size is invalid
Article ID: |
35007 |
Software: |
ArcGIS-arceditor 9.3, 9.3.1, 10 ArcGIS-ArcInfo 9.2, 9.3, 9.3.1, 10 ArcGIS-ArcView 9.2, 9.3, 9.3.1, 10 |
Platforms: |
N/ |
Error messagewhen 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 ."
Causethe fdo_e_invalid_grid_size error is raised because the grid size of the feature class where the feature is being created is too small to handle the feature. This error only occurs with file or ArcSDE geodatabases.
Solution or workarounddepending on how the error message is being raised, there are two different ways to handle the error.
- If this error is encountered while editing within 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 within arccatalog. this requires the use of the Stop editing function, save any edits, and close the map document containing the feature class. for steps on how to recalculate or modify the grid size of a feature
Class, see the following web help documentation: Setting spatial indexes.
- If this error is being encountered programmatically through the ArcObjects API, policying the user to manually modify the spatial index is not an ideal solution. Instead, this error can be prevented
By placing the feature class into loadonly mode prior to inserting the feature. when the feature class is taken out of loadonly mode, the Geodatabase automatically recalculates an appropriate grid size. the following code sample demonstrates how to use loadonly
Mode with a feature class:
'Place the feature class in loadonly mode. This steps needs to happen prior to 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, the Geodatabase will calculcate an appropriate grid size based on the features within the feature class
pFCLoad.LoadOnlyMode = False
Label: arcengine