AnsweredAssumed Answered

Extracting X, Y, Z from line features vertices and create a point feature class

Question asked by richan01 on Jul 30, 2012
Latest reply on Aug 3, 2012 by richan01
I'm trying to create a point feature class using vertices from a line feature class that will add the X, Y, and Z-values. I can't figure out how to get the Z-values to the point feature. I manage to get the X and Y but the Z-values always results in 0. The ptList have Z-values from the vertices but I can't get them to the point feature. I am interested in a solution using python, not using a tool like Vertices To Points.

import arcpy  # Set the outputZFlag environment to Enabled arcpy.env.outputZFlag = "Enabled"   # Input feature class inFC = arcpy.GetParameterAsText(0) outFC = arcpy.GetParameterAsText(1)   # Create describe desc = arcpy.Describe(inFC) shapefieldname = desc.ShapeFieldName inFCDataType = desc.DataType   # Create point list ptList = []   # Create cursor and iterate through objects in feature class rows = arcpy.SearchCursor(inFC) for row in rows:     # Create the geometry object "feat"     feat = row.getValue(shapefieldname)     partnum = 0     # Step through each part of the feature and append vertice coordinates to point list     for part in feat:         part_list = []         for pnt in feat.getPart(partnum):           ptList.append([pnt.X, pnt.Y, pnt.Z])         partnum += 1   # Create point object, point geometry list and iterate through list # and append every coordinate pair to geometry list.  pt = arcpy.Point() ptGeoms = [] for p in ptList:   pt.X = p[0]   pt.Y = p[1]   pt.Z = p[2]   ptGeoms.append(arcpy.PointGeometry(pt))   # Create point feature class, outFC)   # Add XY to point feature class

Any help would be greatly appreciated!