Select to view content in your preferred language

Error Code 000964 after running arcpy.management.Clip

3086
5
Jump to solution
10-04-2018 07:49 AM
JimFritz
Regular Contributor

In the following script an Error Code 000964 keeps coming up.  Any help on this would be great. 

import arcpy
arcpy.env.overwriteOutput = 1
arcpy.env.workspace = r"S:/General-Offices-GO-Trans/SLR-Mapping/GIS_Projects_2018/Smart_T_Line_Model/geodata/TEST_LINES.gdb/"
outbufferpath = r"S:/General-Offices-GO-Trans/SLR-Mapping/GIS_Projects_2018/Smart_T_Line_Model/geodata/TEST_BUFFER.gdb/"
outrasterpath = r"S:/General-Offices-GO-Trans/SLR-Mapping/GIS_Projects_2018/Smart_T_Line_Model/geodata/TEST_RASTERCLIP.gdb/"
outrastertopoint = r"S:/General-Offices-GO-Trans/SLR-Mapping/GIS_Projects_2018/Smart_T_Line_Model/geodata/TEST_RASTERTOPOINT.gdb/"
raster = r"S:/General-Offices-GO-Trans/SLR-Mapping/GIS_Projects_2018/Smart_T_Line_Model/geodata/STLM_NSP.gdb/MN_DEM3second"
featureClassList = arcpy.ListFeatureClasses()
arcpy.env.workspace = outbufferpath
featureClassList = arcpy.ListFeatureClasses()
for featureClass in featureClassList:
    for row in arcpy.da.SearchCursor(featureClass,'SHAPE@'):
        coords = ("row[0].extent.XMin&" "& row[0].extent.YMin&" "& row[0].extent.XMax&" "& row[0].extent.YMax")
        arcpy.management.Clip(raster, coords, outrasterpath + featureClass, featureClass, "255", "ClippingGeometry", "MAINTAIN_EXTENT")
Traceback (most recent call last):
  File "<string>", line 4, in <module>
  File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\management.py", line 15215, in Clip
    raise e
  File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\management.py", line 15212, 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 496, in <lambda>
    return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: ERROR 000964: Specified extent is invalid
Failed to execute (Clip).

NOTE:  Line 8 was not intended.  Also, not sure an ampersand (&) needs to be placed after .YMAX

THANKS to anyone who can uncover the problem.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
JimFritz
Regular Contributor

Thanks for the response.

So, will the line of code (below) work for in my script?

coords = ("{} {} {} {}".format(row[0].extent.XMin, row[0].extent.YMin, row[0].extent.XMax, row[0].extent.YMax))

Jim

View solution in original post

0 Kudos
5 Replies
BrittneyWhite1
Esri Contributor

After you define your coords variable, try adding a print(coords) to uncover the problem.

When I did this with some test data, print(coords) yielded a string: "row[0].extent.XMin&& row[0].extent.YMin&& row[0].extent.XMax&& row[0].extent.YMax"

The way you are defining the coords variable it is not filling in any of the extent values.

You may consider using the string format method to fill in the values for the coords variable:

coords = ("{} {} {} {}".format(row[0].extent.XMin, row[0].extent.YMin, row[0].extent.XMax, row[0].extent.YMax))

For more info on the string format method, see: 6.1. string — Common string operations — Python 3.4.9 documentation 

0 Kudos
JimFritz
Regular Contributor

Thanks for the response.

So, will the line of code (below) work for in my script?

coords = ("{} {} {} {}".format(row[0].extent.XMin, row[0].extent.YMin, row[0].extent.XMax, row[0].extent.YMax))

Jim

0 Kudos
BrittneyWhite1
Esri Contributor

It should work for getting the four extent values and adding a space between each. You can always check by printing out what is stored in the coords variable.

0 Kudos
JimFritz
Regular Contributor

YES, worked just fine. Thanks for the timely response!

Jim

0 Kudos
BrittneyWhite1
Esri Contributor

Glad it worked!

0 Kudos