I am trying to create an arcpyArcPy script that will read a raster cell value at the start point and end point of a polyline, and flip the line based on those values. I
I do not want to create another feature class, I just want to edit a feature class in a gdban existing file geodatabase. I
I am able to get the cell values at the nodes, however, the lines are not flipping direction, so I think the problem lies within the second for loop. Is
Is there a way to do this without writing the geometries to a list and reversing the order because I have had more trouble trying to do jusjust that? Any insight is appreciated and thanks for your help!
The code is as follows:
import arcpy
inFeatures = "Lines"
shapeName = arcpy.Describe(inFeatures).shapeFieldName
rows = arcpy.SearchCursor(inFeatures)
Raster = 'srtm2f.tif'
for row in rows:
feat = row.getValue(shapeName)
xy1 = feat.firstPoint
xy2 = feat.lastPoint
resultSTART = arcpy.GetCellValue_management(Raster, str((xy1)), "1")
CellValueSTART = float(resultSTART.getOutput(0))
resultEND = arcpy.GetCellValue_management(Raster, str((xy2)), "1")
CellValueEND = float(resultEND.getOutput(0))
for features in inFeatures:
if CellValueSTART < CellValueEND:
arcpy.FlipLine_edit(inFeatures)
elif CellValueSTART > CellValueEND:
print 'Feature was correctly digitized'
elif CellValueSTART == CellValueEND:
print 'Feature had same elevation'