Add Spatial Index (Data Management)

Summary

Adds a spatial index to a shapefile, file geodatabase, mobile 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.

Learn more about spatial indexes in the geodatabase

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.

Parameters

LabelExplanationData Type
Input Features

An enterprise geodatabase feature class, file geodatabase feature class, mobile 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

LabelExplanationData Type
Updated Input Features

The updated input features.

Feature Layer; Mosaic Layer

arcpy.management.AddSpatialIndex(in_features, {spatial_grid_1}, {spatial_grid_2}, {spatial_grid_3})
NameExplanationData Type
in_features

An enterprise geodatabase feature class, file geodatabase feature class, mobile 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

NameExplanationData Type
out_feature_class

The updated input features.

Feature Layer; Mosaic Layer

Code sample

AddSpatialIndex example 1 (Python window)

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")
AddSpatialIndex example 2 (stand-alone 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 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

Related topics