数据准备:一个有多个shp数据的文件夹,一个被裁剪的shp文件,这两个分别存放。
# -*- coding: utf-8 -*-
import arcpy
# 多个shp文件所在文件夹
z_shp = "F:/beijing_late/buffer_clip/buf_500/"
arcpy.env.workspace = z_shp
shps = arcpy.ListFiles("*.shp")
# 输出shp所在路径
output_shp = "F:/beijing_late/archi/clip/buf_500/"
# 用于裁剪的shp
archi_shp = "F:/beijing_late/archi/tif/Beijing_Buildings_DWG-Polygon.shp"
for shp in shps:
# 获取shp名称
catchment_name = shp[:-4]
# 输出文件名称
out_feature_class = output_shp + catchment_name
# 调用ArcGIS操作
arcpy.Clip_analysis(archi_shp, shp, out_feature_class, "")
print "finished"