debug python script

272
1
Jump to solution
10-02-2018 06:22 AM
JimFritz
Occasional Contributor
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"

# BUFFER LINE FEATURES FROM RAW LINE DATA FOLDER TEST_LINES.GDB"

featureClassList = arcpy.ListFeatureClasses()
for featureClass in featureClassList:

arcpy.Buffer_analysis(featureClass, outbufferpath, "1250 Feet", "FULL", "ROUND", "NONE")

There is an error somewhere in the arcpy.Buffer_analysis line of code.  Can anyone assist?

Thanks!

Here is what is returned after arcpy command:

arcpy.analysis.Buffer(featureClass, outbufferpath + featureClass, "1250 Feet", "FULL", "ROUND", "NONE")

Traceback (most recent call last):

File "<string>", line 1, in <module>

File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\analysis.py", line 1098, in Buffer

raise e

File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\analysis.py", line 1095, in Buffer

retval = convertArcObjectToPythonObject(gp.Buffer_analysis(*gp_fixargs((in_features, out_feature_class, buffer_distance_or_field, line_side, line_end_type, dissolve_option, dissolve_field, method), 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 000229: Cannot open T_0517__BRI_DJS_TP_34_5_1Failed to execute (Buffer).

0 Kudos
1 Solution

Accepted Solutions
JoeBorgione
MVP Esteemed Contributor

It maybe a typo, but line 15 needs to be indented.  As far as the error goes, is T_0517__BRI_DJS_TP_34_5_1 a valid feature class?  I wonder if you may need to add a make feature layer in there. For example (untested):

featureClassList = arcpy.ListFeatureClasses()
for featureClass in featureClassList:

    arcpy.MakeFeatureLayer_management(featureClass,featureClass_layer)

    arcpy.Buffer_analysis(featureClass_layer, outbufferpath, "1250 Feet", "FULL", 
    "ROUND", "NONE")
That should just about do it....

View solution in original post

1 Reply
JoeBorgione
MVP Esteemed Contributor

It maybe a typo, but line 15 needs to be indented.  As far as the error goes, is T_0517__BRI_DJS_TP_34_5_1 a valid feature class?  I wonder if you may need to add a make feature layer in there. For example (untested):

featureClassList = arcpy.ListFeatureClasses()
for featureClass in featureClassList:

    arcpy.MakeFeatureLayer_management(featureClass,featureClass_layer)

    arcpy.Buffer_analysis(featureClass_layer, outbufferpath, "1250 Feet", "FULL", 
    "ROUND", "NONE")
That should just about do it....