Using ArcPy (Python 3), I am trying to create points along a line where the elevation changes by 1 ft between vertices. I wascan successfully able to convert my streamStream Polyline feature class to 3D using a Water Surface Grid and create a Point feature class where the Interpolate Shape toolelevation changes every 1 ft. When I trynow need to printadd the Z coordinateelevation from the vertex to the Point feature class. Can I get this error:
TypeError: 'float' objectdo by using an Update Cursor within the Insert cursor? I'm still pretty new with Python, what I remember from class is not iterablethat it's bad practice to create nested cursors? What other approach could I use to do this?
import arcpy
import os
from arcpy import env
arcpy.env.overwriteOutput = True
arcpy.CheckOutExtension("3D")
arcpy.CheckOutExtension("Spatial")
env.workspace = r"Ir"C:\1006\GIS\Tools\BFE_Tool\BFE_Tool\BFE_Tool.gdb"
streams = 'ShadrackChannel''FY16_Streams_Diss' # Streams must be dissolved by stream name
outGDB = r'C:\BFE_Tool.gdb'
print ('Interpolating shape...')
stream3D = arcpy.InterpolateShape_3d(r'Ir'C:\1006\GIS\Tools\BFE_Tool\Test_Data\wsg100x'\Test_Data\wsg100x', streams, 'ShadrackChannel_3D''FY16_Streams3D')
print ('Interpolate shape done!')
print ('Looping'Creating throughBFE polyline.Points...')
try:
#
Enter for loop formyLayer each= featurestream3D
for row in prev = -1
heightDiff = 1
pntList = list()
with arcpy.da.SearchCursor(stream3D, ["OID@"myLayer, "SHAPE@Z"]["SHAPE@"]) as cursor:
# Print the current polygonfor orrow polyline'sin IDcursor:
print("Feature {}:".format geom = row[0][0] # A whole polyline
for i, point in enumerate(row[0])geom):
partnum = 0
if prev == -1:
# Step through each part of the feature prev = point.Z
for part in row[1] else:
# Print the part number
printif abs("Partpoint.Z {}- prev) > heightDiff:"
pntList.formatappend(partnum)geom[i - 1])
# Step through each vertex in the feature pntList.append(geom[i])
for pnt in part:
prev = point.Z
if pntlen(pntList) > 0:
print('Creating Empty point feature class...')
# Print z coordinates ofoutFC current= point
arcpy.CreateFeatureclass_management(outGDB, 'BFE_Points','POINT') # Create Empty Feature Class to store Points
print("{}"'Adding Elevation field to Points.format(pnt.Z.') # Add field in Points to store Water Surface Grid Elevations
arcpy.AddField_management(outFC, 'WS_Elev', 'FLOAT')
with arcpy.da.InsertCursor(outFC, ["SHAPE@"]) as elsecursor:
for point in pntList:
# If pnt is None, this represents an interior ring cursor.insertRow([point])
print("Interior'Points Ring:"Created')
except arcpy.ExecuteError:
# Geoprocessor threw an partnumerror
+= 1 print(arcpy.GetMessages(2))
print ('Done'Finished!')
Also how can I create a point where the elevation changes every 1 foot?