Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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 ;)

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer
    
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 Apr 14 at 11:39
1  
Does your feature class allows Z values? –  cag Apr 14 at 12:18
    
Actually no ^^^I changed it and it's work. –  Panvjim0 Apr 14 at 13:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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