Identify and remove collinear vertices from polyline
Summary :: Usage :: Parameters :: Outputs :: Warnings :: Limitations :: Code sample
Summary
Searches for collinear points within a polyline and optionally removes them.
Removal of collinear points is done in situ and thus alters the base network, consider working from a backed up copy!
Usage
Use this tool to identify polylines containing collinear vertices and optionally remove them. A polylines vertices are considered collinear when a sequence of vertices have a constant slope. When determining if vertices are collinear only the XY coordinates are considered. If the vertices have Z or M values then these are ignored when calculating the slope between vertices. Two examples of polylines displaying their vertices are shown below. In both cases you can observe a set of vertices that if removed do not alter the shape or length of the polyline.
Removing collinear vertices removes redundant complexity from the dataset and reduces dataset size.
Removing collinear vertices is an optional quality control and leaving them does not impact on the topology of the network. You can think of removing collinear vertices as an opposite to the densify polyline tool. You may not want to remove collinear vertices if the polyline is Z-enabled as you would loose any detail in elevation.
If a selection exists you can choose to process only those, leaving the Process only selected polylines unchecked will cause RivEX to clear any selection on the network.
The default behaviour of the tool is to log polylines in the error log table, tblCollinearVertices when collinearity is identified. If you check on Remove collinear points then RivEX will also remove the collinear points.
Polylines that are NULL, multi-part or contain Bezier curves are skipped and logged in the error log table. Polylines composed of only two vertices are skipped as the line must be straight, thus only polylines with 3 or more vertices are checked for collinearity.
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 |
Remove collinear points |
The default behaviour of this tool is to identify polylines with collinear vertices and log them in the error log table tblCollinearVertices, no changes are made to the polyline. You can choose to remove the collinear vertices by ticking on this option.
|
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
This tool creates a stand alone table named tblCollinearVertices, if any polylines are found to contain collinear vertices. 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
Removing collinear vertices is editing the river network in situ and there is no undo for this action, consider working from a backed up version of 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.
Limitations
Polylines that are NULL, multi-part or contain Bezier curves are skipped and logged in the error log table
To over come floating point rounding issues in python, when determining the slope between two vertices RivEX truncates the XY coordinates to 6 decimal places. On rare occasions this may itself introduce a rounding issue and RivEX fails to identifying collinearity within a polyline.
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
res = arcpy.scrQCRemoveCollinearPoints_RivEX(fc, False, 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")