wgivens

getting started with Python

Discussion created by wgivens on Aug 8, 2011
Latest reply on Aug 9, 2011 by wgivens
Well, finally breaking down and trying to get going with Python.  My first attempt is to create a batch raster clip tool that loops through a set of rasters, clips them, and saves then to another directory with "_clip" appended to the file name.  The script below runs with no errors.  Problem is no results either.  Any ideas, or thoughts to get me going in the right direction?

import arcpy
import os

inDIR = "C:/Temp/imagery"
outDIR = "C:/Temp/imagery/clipped"
clipFC = "C:/Temp/imagery/clip_feature.shp"

arcpy.env.workspace = inDIR

rasters = arcpy.ListRasters("*", "TIFF")

for raster in rasters:
 print raster
 outname = raster[:-4] + "_clip.tif"
 arcpy.Compression= "LZW"
 arcpy.Clip_Management(raster, "#", os.path.join(outDIR, raster), clipFC, "#", "ClippingGeometry")



Thanks!
Wade

Outcomes