计算默认空间格网索引 (数据管理)
用法
语法
CalculateDefaultGridIndex_management (in_features)
参数 | 说明 | 数据类型 |
in_features |
要计算有效空间格网索引的要素。 | Feature Layer; Raster Catalog Layer |
代码示例
计算默认格网索引示例(Python 窗口)
以下 Python 窗口脚本演示了如何在即时模式下使用 CalculateDefaultGridIndex 功能。
import arcpy from arcpy import env env.workspace = "C:/data" arcpy.CalculateDefaultGridIndex_management("rivers.shp")
计算默认格网索引示例 2(独立脚本)
以下独立脚本将在工作流中使用 CalculateDefaultGridIndex 功能更新 FC 的空间索引。
# Name: UpdateSI_Example.py # Description: Use Calculate Default Grid Index to update the spatial index of a FC # Author: ESRI # Import system modules import arcpy from arcpy import env # Set the workspace 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, RemoveSpaitalIndex will fail, but just keep going pass # Now add the indexes calculated by the tool arcpy.AddSpatialIndex_management(inFeatures, indexGrids) except Exception, e: # If an error occurred, print line number and error message import traceback, sys tb = sys.exc_info()[2] print "Line %i" % tb.tb_lineno print e.args[0]
环境
此工具不使用任何地理处理环境
相关主题
许可信息
ArcView: 是
ArcEditor: 是
ArcInfo: 是
7/10/2012