Reverse the orientation of polylines using elevation data
- The technique described here allows you to reverse the orientation of polylines based upon upstream and downstream elevation values encoded in the polyline dataset .
- How do you get elevation values into your polyline dataset? Simply extract the nodes of the network and use these to query a DTM/TIN. Join the Node data (now with elevation values) to your polyline dataset and then manually copy over the elevation values such that you end up with a polyline dataset that has: ID, From-Node ID, To-Node ID, Upstream elevation and Downstream elevation fields.
- You can then use a calculate script from this web page to reverse the orientation so that polylines flow in a source to river mouth direction.
- Prepare your polyline data by copying elevation values into 2 fields called [UpEle] and [DownEle]. Make sure you are using these field names as these are what the script is looking for.
Your data may have elevation already encoded into it but if it does not then you can use the following technique to copy elevation values into your polyline dataset. Make sure you join the the Nodes to the correct Node field in the polyline data as discussed below!
- Extract nodes using RivEX.
- Assign elevation values to the nodes using a geo-processing tool such as surface spot (3D Analyst). This tool takes a point dataset (in this case your river nodes) and uses them to query a DTM. This particular tool writes back the elevation value to the point dataset using the default field name spot.
- Add two new fields called [upEle] & [DownEle] to your polyline layer. Do not include the [] brackets.
- Create a Join using the Fnode field in the polyline table with NodeID field in node table. Note: you are joining the Node layer to the Polyline layer, not the other way around!
- Do a calculate on [upEle] and copy the elevation values into it. As you have joined the Node layer to the polyline layer in step 4, you will see the elevation field to copy (if you have used the surface spot tool then the field name is spot).
- Having copied the elevation values into [UpEle] remove the Join.
- Create a new join using Tnode with NodeID. Note: you are joining the Node layer to the Polyline layer, not the other way around!
- Do a calculate on [DownEle] and copy the elevation values into it.
- Remove Join.
- Open the attribute table for the polyline dataset and right click on the Shape Field and select "Calculate values. . .". If you are an ArcGIS 9.3 user you will have to highlight the Shape Field column and then press SHIFT + CRTL + F altogether to open the Field calculator at the Shape field.
- Click on the Load. . . button and load the calculation script which you can download here (make sure you save it with a .cal file name extension) . Click on OK to complete the calculation.
- All polylines will be re-orientated if their From-Node elevation [FromEle] is less than their To-Node [ToEle] elevation. If a polyline was pointing in a downstream direction then its from-node must be higher than its to-node.
- A limitation of this script is when the upstream and downstream elevations are both the same. The script will not attempt to flip such a polyline. You should check the output and manually correct the polyline if you come across this situation. Also be aware that the technique you use to attribute the nodes with elevation may also cause inverted values due to imperfections within the base dataset. To identify potential errors of un-flipped polylines you could simply do an attribute query where UpEle = DownEle.
