arcgisscripting.ExecuteError: ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (http://esriurl.com/support)

678
4
Jump to solution
08-30-2021 09:29 PM
Anzhzhi
New Contributor II

I want to use ArcPy to clip a raster. This is a very brief script, but an error appears and I can't find the reason.

The script:

import arcpy
 
arcpy.env.overwriteOutput = 1
arcpy.env.workspace = "D:\\outputData"
arcpy.ClearWorkspaceCache_management()
 
# Specify the input raster
#myData = input("Please specify the input raster")
inputData = "D:\\quad_dem10"
 
# Create an object named rasData. A property of the object is exent
rasData = arcpy.Describe(inputData)
print(rasData.extent)
 
# the cookie cutter is hard coded in. This is a simple approach.
cookieCutter = "398720 4428155 404145 4435160"
 
# Name the output raster's name
outputData ="D:\\outputData"
arcpy.Clip_management(inputData,cookieCutter,outputData)

 

The error:

File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 18832, in Clip
raise e
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 18829, 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 512, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (http://esriurl.com/support) to Report a Bug, and refer to the error help for potential solutions or workarounds.
Failed to execute (Clip).

 

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Regular Contributor
# here you specify D:\outputData as workspace (a folder)
arcpy.env.workspace = "D:\\outputData"

# this only works with Enterprise geodatabase connections. if you don't have any of those, you don't need this
arcpy.ClearWorkspaceCache_management()
 
# does the raster have a file extension?
inputData = "D:\\quad_dem10"

# here you specify D:\outputData as a raster. but it is a folder...
outputData ="D:\\outputData"


# things to check:
#    is D:\outputData a folder?
#        if yes, change your Clip output to D:\outputData\outputRasterName
#        if no, delete the arcpy.env line (you can probably do that anyway)
#    open the tool (Data Management Tools -> Raster -> Raster Processing -> Clip), put in the parameters from your script and try running it manually

Have a great day!
Johannes

View solution in original post

0 Kudos
4 Replies
JohannesLindner
MVP Regular Contributor
# here you specify D:\outputData as workspace (a folder)
arcpy.env.workspace = "D:\\outputData"

# this only works with Enterprise geodatabase connections. if you don't have any of those, you don't need this
arcpy.ClearWorkspaceCache_management()
 
# does the raster have a file extension?
inputData = "D:\\quad_dem10"

# here you specify D:\outputData as a raster. but it is a folder...
outputData ="D:\\outputData"


# things to check:
#    is D:\outputData a folder?
#        if yes, change your Clip output to D:\outputData\outputRasterName
#        if no, delete the arcpy.env line (you can probably do that anyway)
#    open the tool (Data Management Tools -> Raster -> Raster Processing -> Clip), put in the parameters from your script and try running it manually

Have a great day!
Johannes
0 Kudos
Anzhzhi
New Contributor II

It's done! Thanks a lot for your help

0 Kudos
DanPatterson
MVP Esteemed Contributor

Clip Raster (Data Management)—ArcGIS Pro | Documentation

It is definitely not a good idea to use a raster that contains only numbers and spaces.

If the cookieCutter is a featureclass, you should use Clip from the Analysis toolset

Clip (Analysis)—ArcGIS Pro | Documentation

*.tif files are the preferred raster format for raster work, you might want to give a try using *.tif files.

Lastly, did you try to clip the raster manually?  If so, did it succeed?  You need to establish valid input/output file types before embarking on scripting your processes.


... sort of retired...
0 Kudos
Anzhzhi
New Contributor II

Thank you for the help~

0 Kudos