Back story, this code is part of a much larger script which loops a few thousand times and takes a few days to finish
I'm currently going through the code and trying to it speed up where possible. Can the following code be speed up?
# select Lines
whereClauseSort = """{} IN (1,2,3) AND {} = 'Pass' """.format('Sorting', 'Group2')
selectionLineFC = r"in_memory\line"
arcpy.Select_analysis(selectionFC, selectionLineFC, whereClauseSort)
# Dissolve selected lines
Dissolve1 = r"in_memory\Dissolve1"
arcpy.Dissolve_management(
selectionLineFC, Dissolve1, "Angle;BEARING",
"Sorting COUNT;Seam First", "MULTI_PART", "DISSOLVE_LINES")
# add attributes
arcpy.AddField_management(
Dissolve1, "Length", "LONG", "", "", "", "Length", "NULLABLE", "NON_REQUIRED")
arcpy.CalculateField_management(
Dissolve1, "Length", "round(!shape.length@meters!,10)", "PYTHON_9.3", "")
# Sort Dissolve selected lines
sort = r"in_memory\Sort1"
arcpy.Sort_management(
'Dissolve1', sort,
'Length DESCENDING;Angle ASCENDING;COUNT_Sorting ASCENDING', 'UR')
# Select first record
sort2 = r"in_memory\Sort2"
sel = arcpy.Select_analysis(sort, sort2, 'OID = 1')
# Buffer first record
convexHullBuff = r"in_memory\convexHullBuff"
convexHullbuff = arcpy.Buffer_analysis(
sel, convexHullBuff, '200 Meters', 'FULL', 'ROUND', 'NONE', '#', 'PLANAR')
# CONVEX_HULL of Buffered first record
ConvexHull = r"in_memory\ConvexHull"
convexHull = arcpy.MinimumBoundingGeometry_management(
convexHullbuff, ConvexHull, "CONVEX_HULL", 'NONE', '#', 'NO_MBG_FIELDS')