I have a river dataset that was digitized both in the direction of flow and opposite the direction of flow. I need to find an automated method to determine which lines were digitized from downstream to upstream and flip them automatically. I do not have spatial, 3D or network analyst. I am looking for a python code. These lines were created in MicroStation using a bare earth LiDAR dataset. They were hand digitized and it is not a stream centerline but a line following the edges of the river.
I do this by creating routes from the lines using the Create Route tool to get the lines with common ID attributes (like a river name) all combined together and oriented in a single direction. Then extract the FROM and TO end points of the original lines into separate point feature classes with the Feature Vertices to Points tool. I use the Locate Features Along Routes tool with the line end points to get the M values of the line end points and select only those records where the ROUTE_ID attribute is shared by the points and export them. Then I join the From points to the original lines on the ORIG_FID and OBJECTID fields and then join the To points to the original lines on the same fields. I select all lines that have To measures that are less than the From measures. These lines were flipped from my desired orientation represented by the route. Then I break the join and apply the Flip Line tool to all the selected lines (make a backup of your lines prior to doing any of this, since this tool directly alters your original line data). Branching routes will create issues and should be simplified to non-branching routes to get the best results. My network is for roads so getting non-branching routes is simpler for me than it will be for you with your rivers, but the effort is worth it and faster and less error prone than any scripts I have seen or created that try to compare line to line.