ArcPy SearchCursor Total length of line per specific attributes

332
0
06-28-2022 10:34 AM
ModernElectric
Occasional Contributor III

I am working on making improvements to my collection of Python scripts to produce statistical data reports on my in-service infrastructure system. Currently, I am using a file GDB with Feature Class to Feature Class AND Summary Statistics tools with SearchCursor tool to produce the counts. However, as my infrastructure grows and becomes more complex, the script is becoming less efficient. 

I figured out how to do a SearchCursor to give me the total counts of a point feature class per specific attribute criteria:

with arcpy.da.SearchCursor("eSUPPORT_STRUCTURE", "SHAPE@", "POLE_OWNER = 806") as cursor:
    rows = {row[0] for row in cursor}
count = 0
for row in rows:
    count += 1
print "MEWCo Poles: %s" % count

 However, what I am trying to do is take this same Cursor and use it to produce the total lengths on a polyline feature class from my existing code:

# Process: Feature Class to Feature Class - 20" Mainline
arcpy.FeatureClassToFeatureClass_conversion(wMain, TempGDB_gdb, "wMain20", "DIAMETER = 20 AND LIFE_CYCLE_STATUS = 8")

# Process: Summary Statistics - 20" Mainline
arcpy.Statistics_analysis(wMain20, wMain20_Statistics, "SHAPE_Length SUM", "")

I am a little stuck trying to work with a polyline FC versus a point FC. Appreciate your help

0 Kudos
0 Replies