Add Spatial Index (Data Management) |
|
Release 9.2
Last modified November 29, 2010 |
![]() ![]() ![]() Print all topics in : "Tools" |
Adds a spatial index to a shapefile, file geodatabase feature class, or ArcSDE feature class.
Spatial indexes are used by ArcGIS to quickly locate features that match a spatial query. For information on spatial indexes in geodatabases, see Setting spatial indexes. For information on spatial indexes in shapefiles, see Creating and updating indexes in shapefiles.
Usage tips
This command will only work with shapefiles, feature classes in an ArcSDE geodatabase, or feature classes in a file geodatabase. Use it to add a spatial index to a shapefile or feature class that does not already have one.
ArcGIS automatically rebuilds the spatial index at the end of certain operations in file and ArcSDE geodatabases to ensure the index is optimal. To learn how ArcGIS manages the spatial index, see Setting spatial indexes.
Once a feature class in a personal geodatabase is created, the spatial index cannot be removed nor modified. Therefore, a spatial index cannot be added to an existing personal geodatabase feature class.
The options Spatial Grid 1, 2, and 3, are used for file and ArcSDE geodatabase feature classes only. If you are unfamiliar with setting grid sizes, leave these options blank and ArcGIS will compute optimal sizes for you.
If the tool is run with all 3 spatial index grid parameters set to 0, a valid set of spatial index grids will be automatically calculated for you.
Adding a new spatial index to an ArcSDE 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.
The following environments affect this tool: output spatial grid and workspace.
Command line syntax
An overview of the Command Line window
AddSpatialIndex_management <in_features> {spatial_grid_1} {spatial_grid_2} {spatial_grid_3}
Parameter | Explanation | Data Type |
<in_features> |
ArcSDE feature class, file geodatabase feature class, or shapefile to which a spatial index is to be added. |
Feature Layer | Raster Catalog Layer |
{spatial_grid_1} |
The two-dimensional grid system that spans a layer, like a locator grid you might find on a common road map. The first, or lowest, grid level has the smallest cell size. One to three 2D grids (also referred to as grid levels), each with a distinct cell size, are created. Set the cell sizes of the other grids to 0 if you only want one; otherwise, set each level at least three times larger than the previous level. |
Double |
{spatial_grid_2} |
The two-dimensional grid system that spans a layer, like a locator grid you might find on a common road map. The first, or lowest, grid level has the smallest cell size. One to three 2D grids (also referred to as grid levels), each with a distinct cell size, are created. Set the cell sizes of the other grids to 0 if you only want one; otherwise, set each level at least three times larger than the previous level. |
Double |
{spatial_grid_3} |
The two-dimensional grid system that spans a layer, like a locator grid you might find on a common road map. The first, or lowest, grid level has the smallest cell size. One to three 2D grids (also referred to as grid levels), each with a distinct cell size, are created. Set the cell sizes of the other grids to 0 if you only want one; otherwise, set each level at least three times larger than the previous level. |
Double |
addspatialindex_management Database Connections\Connection to esoracle.sde\LPI.Land\LPI.PLSSFirstDivision 1000 3000 10000
Scripting syntax
About getting started with writing geoprocessing scripts
AddSpatialIndex_management (in_features, spatial_grid_1, spatial_grid_2, spatial_grid_3)
Parameter | Explanation | Data Type |
in_features (Required) |
ArcSDE feature class, file geodatabase feature class, or shapefile to which a spatial index is to be added. |
Feature Layer | Raster Catalog Layer |
spatial_grid_1 (Optional) |
The two-dimensional grid system that spans a layer, like a locator grid you might find on a common road map. The first, or lowest, grid level has the smallest cell size. One to three 2D grids (also referred to as grid levels), each with a distinct cell size, are created. Set the cell sizes of the other grids to 0 if you only want one; otherwise, set each level at least three times larger than the previous level. |
Double |
spatial_grid_2 (Optional) |
The two-dimensional grid system that spans a layer, like a locator grid you might find on a common road map. The first, or lowest, grid level has the smallest cell size. One to three 2D grids (also referred to as grid levels), each with a distinct cell size, are created. Set the cell sizes of the other grids to 0 if you only want one; otherwise, set each level at least three times larger than the previous level. |
Double |
spatial_grid_3 (Optional) |
The two-dimensional grid system that spans a layer, like a locator grid you might find on a common road map. The first, or lowest, grid level has the smallest cell size. One to three 2D grids (also referred to as grid levels), each with a distinct cell size, are created. Set the cell sizes of the other grids to 0 if you only want one; otherwise, set each level at least three times larger than the previous level. |
Double |
import arcgisscripting gp = arcgisscripting.create() # Set a default workspace gp.workspace = "c:/test_data" # Set a default workspace gp.toolbox = "management" try: # Add a spatial index to an SDE feature class. gp.addspatialindex ("Database Connections/Connection to esoracle.sde/LPI.Land\LPI.PLSSFirstDivision", 500) except: # If an error occurs when running addspatialindex, print out the error message. print gp.GetMessages(2)