A quick tour of setting a spatial index
The spatial index is used to locate features quickly when you display, edit, or query data. Therefore, a spatial index is important, especially when you are working with large amounts of data.
Spatial indexes work differently depending on the data source. Personal, file and enterprise geodatabases in DB2, enterprise geodatabases in Oracle and SQL Server that use binary geometry storage, and enterprise geodatabases in Oracle that use ST_Geometry storage use a grid-based spatial index. Oracle Spatial, Informix, and PostgreSQL do not use grid sizes—they use an R-tree index. Similarly, feature classes that use SQL Server spatial types do not use an Esri spatial grid index.
How ArcGIS maintains spatial indexes
ArcGIS automatically rebuilds the spatial index at the end of certain operations in file, enterprise, workgroup, and desktop geodatabases to ensure that the index is optimal. The following explains how ArcGIS manages the spatial index:
- When you create an empty feature class with the New Feature Class wizard, a spatial index is created for file, workgroup, desktop, and all enterprise geodatabases except those in DB2 databases. The spatial index will be used when editing or when using the Load Data command(s). In enterprise geodatabases in DB2, the spatial index is created after data is loaded into the empty feature class.
- If you import data from a personal geodatabase, shapefile, or coverage or import computer-aided drafting (CAD) or Smart Data Compression (SDC) data to a file, enterprise, workgroup, or desktop geodatabase, a spatial index is automatically computed for the new feature class.
- When using the ArcCatalog Copy and Paste commands to copy a feature class from a personal geodatabase to a file, enterprise, workgroup, or desktop geodatabase, the spatial index is automatically rebuilt. The spatial index is also rebuilt if you copy a feature class from Oracle Spatial, PostgreSQL, or Informix. If you copy a feature class from a file or an enterprise geodatabase that uses a grid-based index (Oracle binary and ST_Geometry, SQL Server binary, or DB2) to another geodatabase that uses a grid-based index, the index is copied along with the source data and not recomputed.
- When you use a geoprocessing tool that creates a feature class, the features in the new feature class are examined, and a new spatial index is automatically computed.
- When you save edits or use the Load Data commands on a feature class that does not have a spatial index, one will be computed for you at the end of the Save Edit or Load Data operation.
- Compressed file geodatabase feature classes do not use the same type of spatial index used in uncompressed feature classes. When you compress a file geodatabase feature class, it's automatically reindexed. This index cannot be modified. When you uncompress the feature class, the same spatial index the feature class had before it was compressed is automatically reestablished.
When to update the spatial index
Because ArcGIS maintains the spatial index in file, enterprise, workgroup, and desktop geodatabases, you seldom need to re-create the spatial index manually. Re-creation of the spatial index is recommended only in the following rare situation:
- Manually recalculate the spatial index after you have added a large number of features that differ in size from the features that are already in the feature class. This applies to adding features in edit sessions only. For example, you may have started an edit session and manually added a large number of line features or used the Object Loader to load them. Many of the features you've added are either considerably longer or shorter than the features already in the feature class. To ensure that the spatial index will work optimally with the new features, it should be updated.
Spatial indexes in personal geodatabases
Whenever you create a feature class in a personal geodatabase, whether with the New Feature Class wizard, a geoprocessing tool, or any other method, the spatial index will be calculated for you by ArcGIS and cannot be modified. The spatial index is based on the horizon of the feature class coordinate system and will always be optimal.