create line-chord from higher point to lower

5069
3
Jump to solution
01-28-2015 07:04 AM
KONPETROV
Occasional Contributor III

1). Hello i want to create 2 species of line. The first i created it with straight segment form editing tools, as for the second i want it to have the same start and end point but to be drawn as a chord on the terrain, and not on the surface of it, to calculate the difference of their heights.Any help? Should i use traverse editing tool for that?

0 Kudos
1 Solution

Accepted Solutions
XanderBakker
Esri Esteemed Contributor

You can use this code:

import arcpy

fc_in = r"C:\Forum\test.gdb\Polyline_chord"
fc_out = r"C:\Forum\test.gdb\Polyline_straight"

sr = arcpy.Describe(fc_in).spatialReference

lines = []
with arcpy.da.SearchCursor(fc_in, ("SHAPE@")) as curs:
    for row in curs:
        polyline_in = row[0]
        polyline_out = arcpy.Polyline(arcpy.Array([polyline_in.firstPoint, polyline_in.lastPoint]), sr)
        lines.append(polyline_out)

    arcpy.CopyFeatures_management(lines, fc_out)

Kind regards, Xander

View solution in original post

3 Replies
XanderBakker
Esri Esteemed Contributor

Can you explain what exactly it is you mean by "chord"? If you have a picture to explain what you are after that would be helpful too.

KONPETROV
Occasional Contributor III

z.jpg

i want to create the green line which will be precisly above the black line, because i want to calculate the differences at their altitudes at the points with red colour

0 Kudos
XanderBakker
Esri Esteemed Contributor

You can use this code:

import arcpy

fc_in = r"C:\Forum\test.gdb\Polyline_chord"
fc_out = r"C:\Forum\test.gdb\Polyline_straight"

sr = arcpy.Describe(fc_in).spatialReference

lines = []
with arcpy.da.SearchCursor(fc_in, ("SHAPE@")) as curs:
    for row in curs:
        polyline_in = row[0]
        polyline_out = arcpy.Polyline(arcpy.Array([polyline_in.firstPoint, polyline_in.lastPoint]), sr)
        lines.append(polyline_out)

    arcpy.CopyFeatures_management(lines, fc_out)

Kind regards, Xander