I am using ArcGIS Pro 2.4.
I want to make a height profile of a line segment. The line has no height information, so I want to transfer height information to the line from a dem.
How can this be done?
There is probably an easier way, but:
You will now have height values for each line segment in the attribute table. If you also want to update the actual Z value you can try:
(Not sure about the geometry handling below, make sure to check output)
import arcpy layer = 'line123_Intersect' #Name of intersect output layer added to the map field_with_z_values = 'grid_code' #Name of field holding z values with arcpy.da.UpdateCursor(layer,['SHAPE@',field_with_z_values]) as cursor: for row in cursor: print(row) newline =  for part in row: newpart =  for pnt in part: pnt.Z=row newpart.append(pnt) newline.append(arcpy.Array(newpart)) row = arcpy.Polyline(arcpy.Array(newline), arcpy.Describe(layer).spatialReference, True) cursor.updateRow(row)