I have a layer of points and a layer of lines (shapefiles), that have been split so the lines have 2 vertices.
If a line touches one of the points I need I would require to change the direction of the line of those lines (flip), Ionly if they touch (intersect) one point. There are no lines with more than 2 vertices, There are no 2 or more points in the same position. I have seen several codes but in this site and I have not been abletried to actually flipadapt them to my lines although I am sure most lines are touching the pointscase, but not succeed. This This code runs without error but it does nothing.
I am using ArcMap 10.6.1. Standard License
points = []
with arcpy.da.SearchCursor(layerP, "SHAPE@") as p_cur:
for row in p_cur:
points.append(row[0])
lines_to_flip = []
sr = arcpy.Describe(layerD).spatialReference
##try:
with arcpy.da.UpdateCursor(layerD, ['OID@', 'SHAPE@']) as dropCursor:
for dropRow in dropCursor:
print str(dropRow[0])
shpLine = dropRow[1]
shpLinePart = shpLine.getPart(0)
first_point = shpLine.firstPoint
last_point = shpLine.lastPoint
for pt in points:
if pt == first_point: # or pt == last_point:
rPnts=arcpy.Array()
for i in range(len(shpLinePart)): rPnts.append(shpLinePart[len(shpLinePart)-i-1])
rPoly =arcpy.Polyline(rPnts)
dropRow[1].shape= rPoly
dropCursor.updateRow(dropRow)
print "Updated"