基于Python的批量裁剪影像
之前用IDL批量裁剪影像的时候发现裁剪出来的是一个矩形,并不能严格按照图形的形状来完成。发现PYTHON在批处理方面的确好用,节约钱,帮代码直接给贴出来,也算为论坛做点贡献,不知道你们还有什么好的方法。分享一下。使用的时候可以参照这个帖子http://bbs.esrichina-bj.cn/esri/thread-82776-1-1.html import arcgisscripting import os #coding=gbk gp = arcgisscripting.create(9.3) gp.AddToolbox ("G:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Spatial Analyst Tools.tbx") gp.CheckOutExtension("Spatial") ws = os.getcwd() print ws children = os.listdir(ws) files = [] for child in children: ext = os.path.splitext(child)[1] if (ext == '.img'): files.append(child) gp.workspace = ws for file in files: InMask = "E:/NDVI/Export_Output.shp" s = os.path.basename(file) obj_name = s[8:15] + '.IMG' gp.ExtractByMask_sa(file, InMask, obj_name) print files print "ok" 不知道怎么贴成代码的形式。 |