返回顶部

收藏

python处理ArcGIS多图层矢量裁剪

更多
# -*- coding: utf-8 -*-

#导入包
import arcpy
import os
import datetime

startTime=datetime.datetime.now()
print "Python Tool Start--------^_^---------"

#裁剪文件的工作空间
InputSpace=r"F:\data\fuzhou_data"
#结果文件的存放目录
OutputSpace=r"F:\data\fuzhou_map_Demo"
#被裁剪文件路径+名称
clip_features=r"F:\data\clip\clip.shp"

#实现的主体,添加个变量用于处理次数
num=1
#设置工作空间
arcpy.env.workspace=InputSpace

for in_features in arcpy.ListFiles("*.shp"):

clipName=os.path.splitext(in_features)[0]
out_features=os.path.join(OutputSpace,clipName)
cluster_tolerance="0.0000001 DecimalDegrees"
print "Execute num=",num,"Chip Feature is:",clipName

try:
arcpy.Clip_analysis(in_features,
clip_features,
out_features,
cluster_tolerance)
print "Finish"
num=num+1

except Exception as e:
print e.message

endTime=datetime.datetime.now()
exeTime=(endTime-startTime).seconds
print "sum=",num,"All Finish,Cost Time is :",exeTime,"s"

标签:python

收藏

0人收藏

支持

0

反对

0

发表评论