Is This Content Helpful?
We're glad to know this article was helpful.
Instructions provided describe how to call the Data Management > Clip tool in Python when a feature class or template raster is used as clipping geometry.
From ArcGIS 9.3, the Clip (management) tool allows a template feature class or raster dataset to be specified as the extent for clipping.
However, because the 'rectangle' parameter of this tool is a required parameter, when the tool is called in Python, a value still needs to be specified for this parameter, even though the tool is going to use the extent of the clipping feature. The correctness of the extent does not matter when the clipping feature is used.
In ArcGIS 9.3 and 9.3.1, any 'rectangle' can be specified in the Clip (management) tool, when a template is specified. The tool uses the extent of the template.
Starting in ArcGIS 10.0, if the ArcPy Python package is being used, the "#" for the 'rectangle' parameter, instead of assigning a dummy extent.
Depending on the Python package, choose the appropriate script below.
##Clip Raster Dataset with feature geometry import arcgisscripting gp = arcgisscripting.create() gp.Clip_management("c:/image.tif", "0 0 1 1", "c:/clip.tif","c:/feature.shp", "0", "ClippingGeometry")
##Clip Raster Dataset with feature geometry import arcpy arcpy.Clip_management("c:/image.tif", "#", "c:/clip.tif","c:/feature.shp", "0", "ClippingGeometry")