赞
踩
环境 arcgis10.2
# -*- coding: cp936 -*- import arcpy import os arcpy.CheckOutExtension("spatial") arcpy.gp.overwriteOutput=1 #所有shp arcpy.env.workspace = u"F:\\shp\\xianshi" #裁剪栅格 raster = r"C:\Users\ZhangWH\Documents\ArcGIS\Default.gdb\Extract_re121" masks= arcpy.ListFeatureClasses() #arcpy.AddMessage(masks) for mask in masks: (filepath, fullname) = os.path.split(mask) (prename, suffix) = os.path.splitext(fullname) out= u"F:\\ndvi\\ex\\"+prename arcpy.gp.ExtractByMask_sa(raster, mask, out) print("OK")
import arcpy
arcpy.CheckOutExtension("spatial")
arcpy.gp.overwriteOutput=1
arcpy.env.workspace = "F:\\20200708草地规划\\草地资源所需资料\\ndvi"
#裁剪栅格
rasters = arcpy.ListRasters("*", "tif")
arcpy.AddMessage(rasters)
#裁剪shp
mask= "F:\20200708草地规划\ndvi\caodi.shp"
for raster in rasters:
print(raster)
out= "F:\\20200708草地规划\\草地资源所需资料\\ndvi\\ex\\"+raster
arcpy.gp.ExtractByMask_sa(raster, mask, out)
print("OK")
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。