I have created the following script, which moves the points from my_input_points_fc to my_output_points_fc by user input Furthermore, the z-values in my_output_points_fc should also be updated. However, after executing the script I get zero values in the my_output_pointy_fc under the height_field. What am I doing wrong?
import arcpy
arcpy.env.overwriteOutput = 1
arcpy.env.workspace = "my_path"
inputFC = "my_input_points_fc"
outputFC = "my_output_points_fc"
xValue = -1
yValue = -1
while xValue == -1:
try:
xOffset = input("Please enter the X coordinate by which the point should be move: ")
xValue = float(xOffset)
except Exception:
print()
print("The entry was not correct! Please try again")
while yValue == -1:
try:
yOffset = input("Please enter the Y coordinate by which the point should move ")
yValue = float(yOffset)
except Exception:
print()
print("The entry was not correct! Please try again")
spatialRef = arcpy.Describe(inputFC).spatialReference
arcpy.management.CreateFeatureclass(arcpy.env.workspace, outputFC, "POINT",inputFC, has_z = "ENABLED", spatial_reference= spatialRef)
cur = arcpy.da.InsertCursor(outputFC, ("SHAPE@XYZ"))
cur2 = arcpy.da.SearchCursor(inputFC, ("SHAPE@X", "SHAPE@Y", "height_field"))
for row in cur2:
insert_row = (row[0] + xValue, row[1] + yValue, row[2])
cur.insertRow([insert_row])
print ("Points have been moved")
del cur
del cur2
del row
arcpy.CreateFeatureclass_management
, dont know if it matters. You are not calculating the "height_field". You are only using the values to set Z. Changecur = arcpy.da.InsertCursor(outputFC, ("SHAPE@XYZ"))
tocur = arcpy.da.InsertCursor(outputFC, ["SHAPE@XYZ", "height_field"])
and modifyinsert_row
row