Reversing polyline direction based on raster value

المشرف العام

Administrator
طاقم الإدارة
I am trying to create an arcpy 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 do not want to create another feature class, I just want to edit a feature class in a gdb. 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 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 jus that? Any insight is appreciated and thanks for your help! The code is as follows:

import arcpyinFeatures = "Lines"shapeName = arcpy.Describe(inFeatures).shapeFieldNamerows = 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'

أكثر...
 
أعلى