I am trying to automate the process of clipping rasters of scanned maps by following the recommendation found here: How To: Clip a raster using the Clipping Geometry option. The rasters are being clipped to the envelope, but not the shape as pixels outside of the polygon are still persisting. The rasters and the feature class are in the same coordinate system.
My footprints are all stored in same feature class with a field 'RasterFile' storing the raster name (e.g. 'raster01.tif'). I have tried creating a feature layer with a query and using Select analysis to select out the footprint for a single raster (see code below). Everything processes, but the shape clip is not honored.
When I just run the Raster Clip tool manually, the clip honors the shape. Any ideas for what I may be missing?
import os
import arcpy
inputFolder = r'..\RasterFolder'
footprints = r'..\GDB.gbb\ScanFootprints'
arcpy.env.workspace = inputFolder
processRasters = arcpy.ListRasters()
for raster in processRasters:
inputRaster = os.path.join(inputFolder, raster)
arcpy.MakeFeatureLayer_management(footprints, "footprint", "RasterFile = '" + raster + "'")
arcpy.Clip_management(inputRaster, '
arcpy.Select_analysis(footprints, footprints + '_temp', "RasterFile = '" + raster + "'")
arcpy.Clip_management(inputRaster, '