I have a multipart polyline FC in an SDE.ST_GEOMETRY EGDB (Oracle 18c).
For testing purposes, I want to create a new polyline FC that only has the first segment of the original lines.
How can I do that using ArcGIS Pro 2.6.8 or ArcMap 10.7.1? (advanced license)
You can try the following:
1. Run Feature Vertices To Points with START (start vertex) option. The output, say startPoints, should contain start points of input lines.
https://pro.arcgis.com/en/pro-app/2.8/tool-reference/data-management/feature-vertices-to-points.htm
2. Run Split Line At Vertices which breaks lines at vertices. Let's call the output splitLines.
https://pro.arcgis.com/en/pro-app/2.8/tool-reference/data-management/split-line-at-vertices.htm
3. Use Select Layer By Location to select splitLines that are "Within a distance" to startPoints. Since the lines should be touching the start points, you can set a very small Search Distance, e.g. 0.01 feature unit. The selected lines should be what you need.
FYI, in Pro 2.9, the Split Line At Vertices tool writes out the following fields in the output feature class:
As a result, you only need to run this tool and then select "ORIG_SEQ = 1" to get the starting segments.
https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/split-line-at-vertices.htm
perhaps
Multipart To Singlepart (Data Management)—ArcGIS Pro | Documentation
if the polyline isn't just a polyline with segments.
then
Delete Identical (Data Management)—ArcGIS Pro | Documentation
on the ORIG_FID in the output, assuming that the first part of the multipart is retained.
This should only work if your multipart polyline is constructed of 2 point segments
with arcpy.da.UpdateCursor("fc_path_or_layer_name", ["SHAPE@"]) as cursor:
for shp, in cursor:
new_path = shp[0][:2] # first part, first and second vertex
new_shp = arcpy.Polyline(new_path, spatial_reference=shp.spatialReference)
cursor.updateRow([new_shp])