Add Spatial Index (Data Management)

License Level:BasicStandardAdvanced

Summary

Adds a spatial index to a shapefile, file geodatabase, or ArcSDE 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 rebuild an existing spatial index.

Usage

Syntax

AddSpatialIndex_management (in_features, {spatial_grid_1}, {spatial_grid_2}, {spatial_grid_3})
ParameterExplanationData Type
in_features

ArcSDE feature class, file geodatabase feature class, or shapefile to which a spatial index is to be added or rebuilt.

Feature Layer; Mosaic Layer; Raster Catalog Layer
spatial_grid_1
(Optional)

The Spatial Grid 1, 2, and 3 parameters apply only to file geodatabase and certain ArcSDE geodatabase feature classes. If you are unfamiliar with setting grid sizes, leave these options as 0,0,0, and ArcGIS will compute optimal sizes for you.

Double
spatial_grid_2
(Optional)

Cell size of the second spatial grid. Leave the size at 0 if you only want one grid. Otherwise, set the size to at least three times larger than Spatial Grid 1.

Double
spatial_grid_3
(Optional)

Cell size of the third spatial grid. Leave the size at 0 if you only want two grids. Otherwise, set the size to at least three times larger than Spatial Grid 2.

Double

Code Sample

AddSpatialIndex Example (Python Window)

The following Python Window script demonstrates how to use the AddSpatialIndex function in immediate mode.

import arcpy
import arcpy.env as ENV
ENV.workspace = "Database Connections/Connection to esoracle.sde"
arcpy.AddSpatialIndex_management("LPI.Land/LPI.PLSSFirstDivision", 500)
AddSpatialIndex Example 2 (stand-alone Python script)

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 SDE feature class.

# Import system modules
import arcpy
import arcpy.env as ENV

# Set workspace
ENV.workspace = "Database Connections/Connection to esoracle.sde"

# Set local variables
in_features = "LPI.Land/LPI.PLSSFirstDivision"
spatial_grid_1 = "500"
spatial_grid_2 = ""
spatial_grid_3 = ""

# Execute AddSpatialIndex
arcpy.AddSpatialIndex_management(in_features, spatial_grid_1)

Environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: Yes
ArcGIS for Desktop Standard: Yes
ArcGIS for Desktop Advanced: Yes
5/7/2015