Any help with the error message below would be appreciated.
Thanks,
arcpy.env.workspace = outbufferpath
featureClassList = arcpy.ListFeatureClasses()
for featureClass in featureClassList:
for row in arcpy.da.SearchCursor(featureClass,'SHAPE@'):
arcpy.management.Clip(raster, row[0].extent, outrasterpath + featureClass, featureClass, -3.402823e+38, "ClippingGeometry", "MAINTAIN_EXTENT")
Traceback (most recent call last):
File "<string>", line 3, 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: Failed to execute. Parameters are not valid.
ERROR 000445: Extension is invalid for the output raster format.
Failed to execute (Clip).
Can you double-check that you have the final slash on outrasterpath? If it's missing and not being concatenated properly, you could get an extension error:
import os
outrasterpath = r"S:/General-Offices-GO-Trans/TEST_RASTERCLIP.gdb"
featureClass = "featureClassName"
path1 = outrasterpath + featureClass
path2 = os.path.join(outrasterpath, featureClass)
print(path1)
print(path2)
S:/General-Offices-GO-Trans/TEST_RASTERCLIP.gdbfeatureClassName
S:/General-Offices-GO-Trans/TEST_RASTERCLIP.gdb/featureClassName
Try printing the following in the cursor:
print(outrasterpath, featureClass, outrasterpath + featureClass)
If you could share the entire script, that may expose more hints, too.
Darrin,
See my responses on GeoNet if you have not already.
Thanks,
Jim
I meant print that in your own script to ensure the values are exactly what you think they should be.
Darren,
Yes, using the actual pathnames gave the right results. There may still be an issue with the extent of the polygon (outrasterpath + featureClass) that is being used to clip the ESRI grid.
Here's the latest on the processing. There is a new line of code that captures the map extent of each:
coords = ("row[0].extent.XMin&" "& row[0].extent.YMin&" "& row[0].extent.XMax&" "& row[0].extent.YMax")
However, the following error is coming up after running the arcpy.management.Clip command.
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 invalidFailed to execute (Clip).
Sorry, but the option to paste into Python script format was not available.
arcpy.management.Clip("mn_dem3second", "-96.4089849445017 44.3526985271761 -96.3990045132265 44.3597455415406", r"\\fnpcpgo07\HOME\FRTJ06\ArcGIS\Projects\Smart_T_Line\Smart_T_Line.gdb\mn_dem3second_Clip7", "T_0519__APH_TP_APH_34_5_1", -3.402823e+38, "ClippingGeometry", "MAINTAIN_EXTENT")
This is the Python command copied from an interactive process for one record that processed correctly.
Maybe this will help?
I'll give that a shot. Thanks all!
Darrin,
Here's the results of your script (which ran fine) and below is the whole script:
import os
outrasterpath = r"S:/General-Offices-GO-Trans/TEST_RASTERCLIP.gdb"
featureClass = "featureClassName"
path1 = outrasterpath + featureClass
path1 = outrasterpath + featureClass
path2 = os.path.join(outrasterpath, featureClass)
print(path1)
S:/General-Offices-GO-Trans/TEST_RASTERCLIP.gdbfeatureClassName
print(path2)
S:/General-Offices-GO-Trans/TEST_RASTERCLIP.gdb\featureClassName
print(outrasterpath, featureClass, outrasterpath + featureClass)
S:/General-Offices-GO-Trans/TEST_RASTERCLIP.gdb featureClassName S:/General-Offices-GO-Trans/TEST_RASTERCLIP.gdbfeatureClassName
Whole script:
import arcpy
arcpy.env.overwriteOutput = 1
# in path to raw line data
arcpy.env.workspace = r"S:/General-Offices-GO-Trans/SLR-Mapping/GIS_Projects_2018/Smart_T_Line_Model/geodata/TEST_LINES.gdb/"
# out path to buffered lines
outbufferpath = r"S:/General-Offices-GO-Trans/SLR-Mapping/GIS_Projects_2018/Smart_T_Line_Model/geodata/TEST_BUFFER.gdb/"
# out path to clipped rasters
outrasterpath = r"S:/General-Offices-GO-Trans/SLR-Mapping/GIS_Projects_2018/Smart_T_Line_Model/geodata/TEST_RASTERCLIP.gdb/"
# out path to raster to point layers
outrastertopoint = r"S:/General-Offices-GO-Trans/SLR-Mapping/GIS_Projects_2018/Smart_T_Line_Model/geodata/TEST_RASTERTOPOINT.gdb/"
# path to dem
raster = r"S:/General-Offices-GO-Trans/SLR-Mapping/GIS_Projects_2018/Smart_T_Line_Model/geodata/STLM_NSP.gdb/MN_DEM3second"
# BUFFER LINE FEATURES FROM RAW LINE DATA FOLDER TEST_LINES.GDB"
featureClassList = arcpy.ListFeatureClasses()
for featureClass in featureClassList:
arcpy.analysis.Buffer(featureClass, outbufferpath + featureClass, "1250 Feet", "FULL", "ROUND", "NONE")
# CLIP THE DEM GRID USING BUFFERED POLYGONS AS INPUT FOR EACH CLIP
arcpy.env.workspace = outbufferpath
featureClassList = arcpy.ListFeatureClasses()
for featureClass in featureClassList:
for row in arcpy.da.SearchCursor(featureClass,'SHAPE@'):
arcpy.management.Clip(raster, row[0].extent, outrasterpath + featureClass, featureClass, -3.402823e+38, "ClippingGeometry", "MAINTAIN_EXTENT")