3

I have a polyline shapefile with the following attributes: start elevation, end elevation, slope and length. I need to split the lines at a specific elevation, using ArcGIS. Essentially, if my line start elev at 79.38m
end elev at 79.19 length of 144m slope of 0.00132

How can I split the line at an elevation of 79.25m? Is there a tool in ArcGIS that will interpolate the line based on the available information and split the line at the location where 79.25m occurs?

1
  • Please choose a single software. Questions asking for solutions in multiple programs will be closed as "too broad" per this site's "one question per question" policy.
    – csk
    Commented Jan 15, 2019 at 17:12

2 Answers 2

1

You can use arcpy. Code below will check Z-values along the line length step by step and split the line (and output a new split feature class) at the Z-value closest to your desired Z. It might not give you exactly the right split position but if you keep the step value as low as possible it should be very Close. With 0.1 m step value i got the split at exactly Z 79.25

import arcpy

fc = r'Polyline_with_Z' #Change
desired_z = 79.25 #Change
step = 0.1 #Change, as small as possible without making the execution time unacceptably long
out_fc = r'in_memory\split_lines'#Change

geom = [i[0] for i in arcpy.da.SearchCursor(fc,"SHAPE@")][0] #If you have more than one line in the in fc you will have to modify this line and code below
points = []
position = 0
while position < geom.length:
    points.append(geom.positionAlongLine(position))
    position+=step

bestpoint = min(points, key=lambda x: abs(x.centroid.Z-desired_z))
arcpy.CopyFeatures_management(in_features=bestpoint, out_feature_class=r'in_memory\bestpoint')
arcpy.SplitLineAtPoint_management(in_features=fc, point_features=r'in_memory\bestpoint', 
                                 out_feature_class=out_fc)

enter image description here

1
  • 1
    Thank you so much this is great! I never even thought to make script...because I'm not very comfortable with arcpy.
    – user132003
    Commented Jan 16, 2019 at 21:14
-1

How do we change this code to iterate through every record in a feature class? I'm stuck here.

import arcpy
fc = r'subset' #Change
desired_z = 3000 #Change
step = 100 #Change, as small as possible without making the execution time unacceptably long
out_fc = r'C:\Users\kdoughty\Downloads\SAN FLIGHT\split_lines2'#Change
with arcpy.da.SearchCursor(fc,"SHAPE@") as cursor:
    for row in cursor:
        points = []
        position = 0
        while position < row[0].length:
            points.append(row[0].positionAlongLine(position))
            position+=step
    bestpoint = min(points, key=lambda x: abs(x.centroid.Z-desired_z))
    arcpy.CopyFeatures_management(in_features=bestpoint, out_feature_class=r'C:\Users\kdoughty\Downloads\SAN FLIGHT\bestpoint')
    arcpy.SplitLineAtPoint_management(in_features=fc, point_features=r'C:\Users\kdoughty\Downloads\SAN FLIGHT\bestpoint', out_feature_class=out_fc)
2
  • Welcome to GIS SE. As a new user, please take the Tour, which explains how our Focused question/Best answer model operates. Unfortunately, you've posted a new Question in an Answer block, which breaks the model. Please ask a new Question.
    – Vince
    Commented Mar 22, 2023 at 22:08
  • If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review Commented Mar 22, 2023 at 22:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.