ArcGIS for Desktop

  • Documentation
  • Pricing
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS for Desktop

A complete professional GIS

ArcGIS for Server

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Pricing
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

Calculate Default Spatial Grid Index

  • Summary
  • Usage
  • Syntax
  • Code sample
  • Environments
  • Licensing information

Summary

Calculates a set of valid grid index values (spatial grid 1, 2, and 3) for the input features. Grid index values will be calculated even if the input features do not support spatial grid indexing.

Learn more about spatial indexes

Usage

  • The grid index values will be returned as a message from the tool. The values can be viewed in the geoprocessing Results window, or the value can be assigned to a variable in scripting by accessing the tool execution result object..

  • The spatial grid index of the Input Features is not updated by this tool. File or SDE geodatabase feature class spatial grid indexes can be modified using the Add Spatial Index tool, or in the feature class property page under the Index tab.

  • The set of values returned by the tool can be used with the Add Spatial Index or Copy Features tools, or for the Output Spatial Grid environment settings.

  • The returned grid size is based on the spatial reference, average feature size, and number of features in the input features.

Syntax

CalculateDefaultGridIndex_management (in_features)
ParameterExplanationData Type
in_features

The features for which a valid spatial grid index will be calculated.

Feature Layer; Raster Catalog Layer

Code sample

Calculate Default Grid Index Example (Python Window)

The following Python window script demonstrates how to use the CalculateDefaultGridIndex function in immediate mode.

import arcpy
arcpy.env.workspace = "C:/data"
arcpy.CalculateDefaultGridIndex_management("rivers.shp")
Calculate Default Grid Index Example 2 (Standalone Script)

The following standalone script uses the CalculateDefaultGridIndex function in a workflow to update the spatial index of a FC.

# Name: UpdateSI_Example.py
# Description: Use Calculate Default Grid Index to update the spatial index of a FC

# Import system modules 
import arcpy

# Set the workspace
arcpy.env.workspace = "C:/data/data.gdb"

# Set local parameters
inFeatures = "river"

try:
    # Get the grid sizes from the tool, this is a string with 3 semi-colon seperated values (typically something like "1500; 0; 0") 
    result = arcpy.CalculateDefaultGridIndex_management(inFeatures)
    indexGrids = []
    for count in range(0, result.outputCount):
        indexGrids.append(result.getOutput(count))

    # First remove the existing grid index
    try:
        arcpy.RemoveSpatialIndex_management(inFeatures)
    except:
        # if no index exists, RemoveSpatialIndex will fail, but just keep going
        pass

    # Now add the indexes calculated by the tool
    arcpy.AddSpatialIndex_management(inFeatures, indexGrids)

except Exception as err:
    print(err.args[0])

Environments

This tool does not use any geoprocessing environments

Licensing information

  • ArcGIS for Desktop Basic: Yes
  • ArcGIS for Desktop Standard: Yes
  • ArcGIS for Desktop Advanced: Yes

Related topics

  • An overview of the Feature Class toolset

ArcGIS for Desktop

  • Home
  • Documentation
  • Pricing
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
© Copyright 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal