Flipping Lines

944
4
06-24-2011 06:21 AM
ManojBanga
New Contributor
Hi all!

I am looking for a python script which can flip all the lines in one direction.

Either north for vertical and east for horizontal lines.

Thanks
Manoj
Tags (2)
0 Kudos
4 Replies
ManojBanga
New Contributor
Hi All!

any solution to this please?
0 Kudos
JakeSkinner
Esri Esteemed Contributor
If you have an ArcEditor license for ArcGIS 10 you can use the 'arcpy.FlipLine_edit' function to reverse the direction of your polyline data.
0 Kudos
ManojBanga
New Contributor
Thanks Jake

but this is not what I am looking for, flip tool just reverse the current direction.

I need a script or method to flip all the lines in ONE DIRECTION.  It can be eaither North or East depending on if its closer to vertical or horizontal direction.

Thanks
0 Kudos
DarrenWiens2
MVP Honored Contributor
I can't write the actual script right now, but here's the method I would follow, in python:

read your lines into a search cursor

for each line in the cursor:
    get the first and last point coordinates
    calculate the change in x # first minus last, negative = W->E
    calculate the change in y # first minus last, negative = S->N
    if the absolute change in x is greater than the absolute change in y: # the line is in horizontal orientation
        if the change in x is positive: # line is E->W
            send line to new feature class to be flipped
            delete line from current feature class
    else: #the line is vertical
        if the change in y is positive: # the line is N->S
            send line to new feature class to be flipped
            delete line from current feature class
flip lines in new feature class
merge flipped lines back into original feature class 
0 Kudos