0

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?

enter image description here

0

There is probably an easier way, but:

  1. Raster to Point, to get points with value of raster in grid_code field
  2. Select points near the line (to speed up next step)
  3. Generate Thiessen Polygons with Output Field = All fields
  4. Intersect line with thiessen polygons.

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:

  1. Read value from grid code field and update Z for every line vertice using arcpy:

(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[0]:
            newpart = []
            for pnt in part:
                pnt.Z=row[1]
                newpart.append(pnt)
            newline.append(arcpy.Array(newpart))
        row[0] = arcpy.Polyline(arcpy.Array(newline), arcpy.Describe(layer).spatialReference, True)
        cursor.updateRow(row)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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