How to update the Z value using an UpdateCursor?

المشرف العام

Administrator
طاقم الإدارة
I have created the following script to mimic the ArcGIS 3D Analyst tool, FeatureTo3DByAttribute, which creates a 3D copy of a 2D feature class and sets the Z to a specified attribute.

import arcpy, osfrom arcpy import env# Parametersin_features = arcpy.GetParameterAsText(0) #Feature Layerout_features = arcpy.GetParameterAsText(1) #Feature Classheight_field = arcpy.GetParameterAsText(2) #Field# disable overwrite protectionarcpy.env.overwriteOutput = True# enable environment outputZFlagarcpy.env.outputZFlag = "Enabled"# copy input to outputarcpy.CopyFeatures_management(in_features, out_features)# Use cursor to update geometry with z value based on height_fieldwith arcpy.da.UpdateCursor(out_features, ("SHAPE@Z", height_field)) as cursor: for row in cursor: row[0] = row[1] cursor.updateRow(row)Unfortunately, the z value is 0 for all of the output features. I can't find any documentation as to why this is. An alternative would be read every point and change the z value. Does anyone know why it is failing to update the z?

EDIT:Additional discussion

https://geonet.esri.com/thread/93322

https://geonet.esri.com/thread/82123



أكثر...
 
أعلى