janver

Finding Z value of a point

Discussion created by janver on Feb 29, 2012
When I try to find the elevation of a point it returns #QNAN. If I test it with HasZ, it returns that it has a Z value and when i check it in edit mode I can see the Z values.  What is wrong with this code that it returns #QNAN instead of the actual z value?

desc = gp.Describe(RO_RoadSegment)
  if not desc.HasZ:
    gp.AddMessage("No Z")
  else:
    gp.AddMessage("Has Z")
                                
  shapefieldname = desc.ShapeFieldName
  curs = gp.SearchCursor(RO_RoadSegment)
  for cur in iter(curs.next, None):
    feat = row.getValue(shapefieldname)
    pnt = feat.getPart()
    gp.AddMessage("X: " + str(pnt.X) + " Y: " + str(pnt.Y) + " Z: " + str(pnt.Z))

Result code:
Has Z
X: 672658.964 Y: 703787.515 Z: 1.#QNAN

Nevermind i found out i made en error in the feat line, it had to point to cur.getValue(shapefieldname) instead of row.getValue(shapefieldname)

Outcomes