1

I am making a python code for arcgis 9.3. In this code i create a new point with x,y and z attributes as following :

rowsLine = gp.updatecursor(line_Feature_Class)
rowLine = rowsLine.next()

rowsPoint = gp.InsertCursor(point_Feature_Class)
feat = rowsPoint.NewRow()

while rowLine:

    #...

    ptObj = gp.CreateObject('Point')
    ptObj.x = xPremierPoint
    ptObj.y = yPremierPoint
    ptObj.z = zPremierPoint
    feat.Shape = ptObj
    rowsPoint.InsertRow(feat)

I want to add the z value in a field "zvalue" in my "point_Feature_Class". The problem is i can't use an insert cursor (rowsPoint) and an update cursor at the same time.

So, at the end of the code, I want to delete the insert cursor, create an upsdate cursor, to loop in my "point_Feature_Class" and get the z attribute of each point and add it in the fiels "zvalue".

The code should be something like that :

rows = gp.updatecursor(point_Feature_Class)
row = rows.next()

While row :

    Zvalue = #???? row.shape.getz ????
    row.SetValue("zvalue", Zvalue)

rows.updateRow(row)
row = rows.Next()

Thanks for your help ;)

1 Answer 1

3

You can get it this way:

row.GetValue("your_shape_field_name").GetPart().z

And here you can get more information and a complete example from the ArcGIS Desktop Help.

3
  • Thanks for the answer ! Now i have a new problem : The value return by this line is 1.#QNAN. It means that no value is set to point.z while i set the vaue prviously : ptObj.z = zPremierPoint. And if i try with .x, it works !
    – Panvjim0
    Commented Apr 14, 2014 at 11:39
  • 1
    Does your feature class allows Z values? Commented Apr 14, 2014 at 12:18
  • Actually no ^^^I changed it and it's work.
    – Panvjim0
    Commented Apr 14, 2014 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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