I am trying to write an ArcGIS script, however, I can't seem to get Clip Raster to cooperate. This is what I have so far:

import arcpy, math

if __name__ == '__main__':
    inDEM = arcpy.GetParameterAsText(0)
    points = arcpy.GetParameterAsText(1)
    bufferSize = arcpy.GetParameterAsText(2)

    arcpy.AddMessage("Creating buffer...\n")
    arcpy.Buffer_analysis(points, "bufferOutput", bufferSize + " meters", dissolve_option = "ALL")

    arcpy.AddMessage("Projecting buffer...\n")
    arcpy.Project_management("bufferOutput", "bufferProject", arcpy.Describe(inDEM).SpatialReference)

    arcpy.AddMessage("Clipping DEM using buffer...\n")
    arcpy.Clip_management(inDEM, "bufferProject", "clippedRaster", clipping_geometry = "ClippingGeometry")

Every single time it throws the following error when it gets to the Clip Raster part.

Traceback (most recent call last):
  File "C:\Users\User\OneDrive\Research\Scripts\script.py", line 22, in <module>
    arcpy.Clip_management(inDEM, "bufferProject", "clippedRaster", clipping_geometry = "ClippingGeometry")
  File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\management.py", line 16854, in Clip
    raise e
  File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\management.py", line 16851, in Clip
    retval = convertArcObjectToPythonObject(gp.Clip_management(*gp_fixargs((in_raster, rectangle, out_raster, in_template_dataset, nodata_value, clipping_geometry, maintain_clipping_extent), True)))
  File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\geoprocessing\_base.py", line 506, in <lambda>
    return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError:  ERROR 000964: Specified extent is invalid
Failed to execute (Clip).
 Failed to execute (script).

Now the first thing I checked was the coordinate systems, but they are the same. Heck, even in my code you can see I set the coordinate system to match. And when I run this exact same setup manually in ArcGIS it works without a hitch.

  • According to the ArcPy spec, the optional parameter clipping_geometry is a boolean, either set to "NONE" or "ClippingGeometry". I do not believe this is related to the clipping extent layer, which is the second parameter.
    – mwsmws22
    Commented Apr 18, 2020 at 19:40
  • Doh. Nevermind.
    – Vince
    Commented Apr 18, 2020 at 20:34
  • It should be noted that the fourth parameter is the clipping extent layer, not the second parameter. This parameter is optional, so watch out.
    – mwsmws22
    Commented Apr 23, 2020 at 21:12

1 Answer 1


I managed to figure out what I was doing wrong. Seems I was confused about the input parameters for Clip_management. Hopefully this can help someone else.

arcpy.Clip_management(inDEM, "", "clipRaster", "bufferProject", clipping_geometry = "ClippingGeometry")

It wasn't clear in the spec, but if you want to use the clipping geometry of an input feature, you have to leave the 'rectangle' parameter blank.

  • Exactly what I needed - thank you! Commented May 27, 2022 at 0:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.