Summary :: Usage :: Parameters :: Outputs :: Warnings :: Limitations :: Code sample


This tool searches for polylines that loop, that is they start and end at the same node.


Closed or "looping" polylines are hard to visually see as they often appear to be short tributaries.  They are only obvious when overlaid with the node layer and you see a polyline which does not have a node at one end. 

In the image below, nodes are indicated by large light green dots.  As you can see there is no node at the downstream end of the selected polyline which means it's downstream node has snapped to the upstream node thus closing the polyline (red cross).  Although this polyline intersects the rest of the network it does not participate in the topology of the network. 

To correct this, the downstream node has been deleted and second vertex now becomes the downstream node of the polyline (green tick). 

The main stream polyline needs to be split at the red downstream vertex and polylines snapped to a new node. 

Cross - bad          

              Tick - good

Closed Polyline Example

Any found to be looping have their polyline ID written to an error log table called tblLooping. If the table already exists then a new table name is created with a simple numeric suffix.

The tool optionally adds the error log table to the map (default) and if selected builds a standard relate between river network layer and error log table. You can use the relate to select and jump to the polyline to streamline your editing experience.




Data type

River Network

The river network. For best results the network should be within a File GeoDatabase

Feature Layer

Add Error Log Table to Map

If this is ticked (default) the error log table will be added to the map for your convenience if any errors were found.


Build a Relate for Error Log

If this tick box is checked then the error log table must be loaded into the map and RivEX builds a standard relate between the Error Log table and the river network layer. You can use the relate to help you jump to and review the error.



This tool creates a stand alone table named tblLooping, if any looping polylines are encountered within the river network.  The table is created in the RivEX workspace folder and stored in the File GeoDatabase found in ..\RivEX_Workspace\ErrorLogs\fGDB_RivEXErrorLogs.gdb

Advice on the structure of the error log table and how it can be used is found within this section of the manual. Take note of the warning if you plan to construct a model using the error log output in subsequent processing.


Having identified looping features and corrected them, you will have changed the topology of the network.  You must re-run your network through the Extract Network Topology and write to Workspace tool to rebuild and correctly attribute the node and polyline fields in your river network.

With the release of ArcGIS Pro 3.2.1 a switch control appears on parameters that accept tables\feature classes, do not interact with it! More advice here.


All polylines in the river network are tested, if a selection existed this is cleared prior to processing.

Code sample

A minimum code example showing how to call this tool in a python script. This can be run in console or your preferred IDE. If you right click on the tool in the RivEX toolbox and select properties you can view parameter order.

import arcpy

# Import RivEX toolbox

    # Input river Feature Class
    fc = r"C:\Temp\ORN\ORN.gdb\ORN"

    # Run RivEX quality control tool
    res = arcpy.scrQCLooped_RivEX(fc, False, False)

    # The rivers Feature Class, a derived output
    fcRivers = res.getOutput(0)
    # Get error table
    tblError = res.getOutput(1)

    # Check if error table exists
    if arcpy.Exists(tblError):
        # Count number of rows
        res = arcpy.GetCount_management(tblError)
        n = int(res.getOutput(0))
        if n > 0:
            print(str(n) + " error(s) were recorded")
        print("No error table created!")
except arcpy.ExecuteError:
    print("FAILED to quality control network")

Return to top of page