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.
Solved! Go to Solution.
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
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
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
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.
YES, worked just fine. Thanks for the timely response!
Jim
Glad it worked!