码迷,mamicode.com
首页 > 其他好文 > 详细

ArcPy 创建图层空间索引

时间:2018-07-26 15:00:25      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:catalog   lse   ini   use   let   alc   col   数据集   tip   

使用Python脚本进行图层的空间索引的创建。

附上Python代码:

 1 # -*- coding: utf-8 -*-
 2 # nightroad
 3 import sys
 4 import arcpy
 5 reload(sys)
 6 sys.setdefaultencoding( "utf-8" )
 7 path = r"C:\Users\Administrator\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\test.sde"
 8 arcpy.env.workspace = path
 9 DSs = arcpy.ListDatasets()
10 # 只对test数据集内的数据进行处理
11 arcpy.env.workspace = str(path) + "\\" + test
12 ff = arcpy.ListFeatureClasses()
13 for fc in ff:
14     try:
15         desc = arcpy.Describe(fc)
16         if (desc.shapeType == "Point") or (desc.shapeType == "MultiPoint"):
17             arcpy.AddSpatialIndex_management(fc, 0, 0, 0)
18             print(Success: + fc +   Create Spatial index Completed)
19         else:
20              indexs = arcpy.CalculateDefaultGridIndex_management(fc)
21              index = int(indexs[0])
22              #针对线面对象创建三层索引
23              arcpy.AddSpatialIndex_management(fc, index, 3*index, 9*index)
24              print(Success: + fc +   Create Spatial index Completed)
25     except:
26         print(Failed: + fc + " error")

 

ArcPy 创建图层空间索引

标签:catalog   lse   ini   use   let   alc   col   数据集   tip   

原文地址:https://www.cnblogs.com/nightroad/p/9371242.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!