Summary
Adds a spatial index to a shapefile, file geodatabase, or enterprise geodatabase feature class. Use this tool to either add a spatial index to a shapefile or feature class that does not already have one or to re-create an existing spatial index.
Usage
ArcGIS uses spatial indexes to quickly locate features in feature classes. Identifying a feature, selecting features by pointing or dragging a box, and panning and zooming all require a spatial index to locate features. The spatial index is defined by using a grid-based system that spans the extent of the features in a feature class, like a locator grid you might find on a common road map.
By default, ArcGIS creates and maintains a spatial index for geodatabase feature classes. For a geodatabase feature class to not have a spatial index, you must explicitly remove it using the Remove Spatial Index tool.
Adding a new spatial index to an enterprise geodatabase feature class is a server-intensive operation. It should not be done on large feature classes when a large number of users are logged in to the server.
For SQL Server and Oracle feature classes, if the index already exists, the index will be dropped and recreated. The bounding box will also be recalculated for SQL Server feature classes.
SAP HANA feature classes do not support spatial indexes.
Syntax
AddSpatialIndex(in_features, {spatial_grid_1}, {spatial_grid_2}, {spatial_grid_3})
Parameter | Explanation | Data Type |
in_features | Enterprise geodatabase feature class, file geodatabase feature class, or shapefile to which a spatial index is to be added or rebuilt. | Feature Layer; Mosaic Layer |
spatial_grid_1 (Optional) | This parameter has been deprecated in ArcGIS Pro. Any value you enter will be ignored. | Double |
spatial_grid_2 (Optional) | This parameter has been deprecated in ArcGIS Pro. Any value you enter will be ignored. | Double |
spatial_grid_3 (Optional) | This parameter has been deprecated in ArcGIS Pro. Any value you enter will be ignored. | Double |
Derived Output
Name | Explanation | Data Type |
out_feature_class | The updated input features. | Feature Layer; Mosaic Layer |
Code sample
The following Python window script demonstrates how to use the AddSpatialIndex function in immediate mode.
import arcpy
arcpy.env.workspace = "c:/Connections/Connection to esoracle.sde"
arcpy.AddSpatialIndex_management("LPI.Land/LPI.PLSSFirstDivision")
The following Python script demonstrates how to use the AddSpatialIndex function in a stand-alone script.
# Name: AddSpatialIndex_Example2.py
# Description: Add a spatial index to a enterprise geodatabase feature class.
# Import system modules
import arcpy
# Set workspace
arcpy.env.workspace = "c:/Connections/Connection to esoracle.sde"
# Execute AddSpatialIndex
arcpy.AddSpatialIndex_management(in_features)
Environments
Licensing information
- Basic: Yes
- Standard: Yes
- Advanced: Yes