Extract first segment of polylines

655
3
06-14-2022 10:18 PM
Labels (1)
Bud
by
Notable Contributor

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.

Bud_0-1655270162782.png

  • For multi-part features, I want to ignore the additional parts. For example, I don't want to get the first segment of the second part.
  • It's a one-time operation, so using geoprocessing tools would be fine (no need for automation or custom scripting).

How can I do that using ArcGIS Pro 2.6.8 or ArcMap 10.7.1? (advanced license)

Tags (2)
0 Kudos
3 Replies
DanLee
by Esri Regular Contributor
Esri Regular Contributor

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:

  • ORIG_FID—Stores the feature IDs of the input features.
  • ORIG_SEQ—Stores the sequence number for each output line following the order of the segments from the starting vertex of the input feature.

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

 

DanPatterson
MVP Esteemed Contributor

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


... sort of retired...
JohannesLindner
MVP Frequent Contributor
  • copy your feature class
  • run the script below (change path to the copy)

 

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])

 

 

JohannesLindner_0-1655282142907.pngJohannesLindner_1-1655282315693.png

 


Have a great day!
Johannes