Remove polyline self-intersections
Summary :: Usage :: Parameters :: Outputs :: Warnings :: Limitations :: Code sample
Summary
Searches for polylines that have self-intersections and removes the vertices causing the polyline to self-intersect. Updated polylines are logged in the error log table.
Usage
This tool searches for polylines that have self-intersections and removes the vertices causing the polyline to self-intersect. You would use this tool to bulk process your entire network. You may not want to run this tool if you prefer to remove the vertex and reshape the polyline manually? If this is the case then simply run the Identify self-intersecting polylines quality control tool to generate a log table of self-intersecting polyline ID's which you use to visit the polyline.
Any found to be self-intersecting have their polyline ID written to an error log table called tblFixedSelfIntersections. If the table already exists then a new table name is created with a simple numeric suffix.
You can choose to process only the selected polylines; otherwise the tool clears any selection and processes the entire dataset.
The tool works by removing vertices until the test polyline stops intersecting itself. It then removes the vertex causing the self-intersection from the polyline itself. It must then repeat the process in case the polyline has multiple self-intersections.
The output of this tool is an amended version of your river network with self intersections removed. There is no undo for this tool!
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.
Parameters
Name |
Help |
Data type |
River Network |
The river network. For best results the network should be within a File GeoDatabase |
Feature Layer |
Process only selected polylines |
Indicate if you wish to processes only selected polylines. |
Boolean |
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. |
Boolean |
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. |
Boolean |
Outputs
The output of this tool is an amended version of your river network with self intersections removed. This tool will also create a stand alone table named tblFixedSelfIntersections, if any self-intersections 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.
Warnings
The fixing of self-intersections is in situ and thus alters the base network, consider working from a backed up copy!
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.
Limitations
This tool uses the python module shapely which must be installed before using RivEX. The tool will reject river networks that are M or Z enabled; you can correct this by using the Copy Features tool and setting the appropriate environment settings to disable ZM values. The tool will abort on the first multi-part geometry or polyline with no ID value it encounters. In these cases you need to find and correct multi-part polylines and\or poorly attributed ID fields.
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
arcpy.ImportToolbox(r"C:\RivEX_ArcPro\RivEX.atbx")
try:
# Input river Feature Class
fc = r"C:\Temp\ORN\ORN.gdb\ORN"
# Run RivEX quality control tool, use seelction set to False as input is a Feature CLass
res = arcpy.scrQCRemoveSelfIntersections_RivEX(fc, False, 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")
else:
print("No error table created!")
except arcpy.ExecuteError:
print("FAILED to quality control network")