AnsweredAssumed Answered

Creating 3D line from points with python

Question asked by Martin-Munin on Sep 16, 2014
Latest reply on Dec 14, 2015 by TanyaKExp

Hi.

 

I have a series of points with X,Y,Z coordinates. I am trying to create a polylines from the points. Points should be vertexes of the polyline and Z-Coordinate should be used to define the elevation of vertexes.

 

I have created a script which works, but the Z-Coordinate is lost on vertexes and is recorded as ZERO. I am sure that my script is correct because if I pass the Z-Coordinate into the M value, it is recorded correctly. The part of the script which creates the line can be seen below:

 

vertexArray = arcpy.Array()

     for points in pointArray:

 

     xCoord = valueX

     yCoord = valueY

     zCoord = valueZ

         

     # valueZ is also passed to M dimension to test if there are some problems with values

     currentPoint = arcpy.Point(valueX, valueY, valueZ, valueZ)

 

     vertexArray.add(currentPoint)

 

newLineCursor = arcpy.da.InsertCursor(outputFc, ["SHAPE@"])

  polyline = arcpy.Polyline(vertexArray)

  newLineCursor.insertRow([polyline])

 

 

The script runs wihtout problems, and the polylines are created. But when I check in ArcMAP the polyline under sketch properties all the vertexes on line have null as Z-Coordinate (see image bellow).

edit sketch properties.jpg

 

I have just tested to convert points with arcpy.PointsToLine_management, and it works correctly. I could implement this in my script, but I am still curious as to why is Z-Coordinate not recorded properly with my script.

 

Thanks,

Martin

Outcomes