1

I am trying to "reverse" the values of Z in a pointMZ geometry with arcpy.da.UpdateCursor. Anyway, I am not able to find a way to achieve this, although my script seems to work (no errors, printing the new Z values gives me the right output, but geometry always looks the same...). My try:

 import arcpy

 with arcpy.da.UpdateCursor('my_feat.shp', "SHAPE@Z") as cursor:     
     for row in cursor:
         row[0] = -1 * row[0]
         print(row[0])
         cursor.updateRow(row)

My pointMZ geometry always looks the same (in terms of points displayed in my scene view), while I expected to set its Z values to their opposites and see them upside down.

3

Your code does work - if you select a point, click the Attribute button under EDIT, and choose Geometry, you'll see your Z-value is negative.

What looks to be happening (or not happening) is the display doesn't immediately recognize that the underlying Z-values have changed. If you remove the layer and re-add it to your map the points will be "below the earth's surface"

  • Indeed. It's working. I just had the same file opened as in a map and a scene at the same time, so I probably wasn't able to see the edits. Thanks for the time! – umbe1987 Nov 2 '15 at 21:43
  • All arcpy.mp API changes should force a refresh. A quick way to do this is: m = arcpy.mp.ArcGISProject("CURRENT").listMaps()[0] to get a Map reference then m.defaultCamera.setExtent(m.defaultCamera.getExtent()) to refresh the extent without changing it, which should refresh the entire interface. – blord-castillo Nov 4 '15 at 14:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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