Find straight segments

This tool can be used to break vector line or polygon files into relatively straight segments. It is most often used for identifying the sides of polygons, e.g. the edges of agricultural fields. The output file is a vector of POLYLINE type, where each feature represents a straight segment from the input vector. The greater the maximum angular deviation parameter, the greater the amount of flexibility in what is defined as a straight segment and vice versa. This parameter should not exceed 90.0 degrees in most cases. If the parameter is set too low, the output vector file will contain many small line segments.

See Also:

Scripting:

The following is an example of a Python script that uses this tool:

wd = pluginHost.getWorkingDirectory()
inputFile = wd + "input.shp"
outputFile = wd + "output.shp"
maxAngularDeviation = "30.0"
args = [inputFile, outputFile, maxAngularDeviation]
pluginHost.runPlugin("FindStraightSegments", args, False)

This is a Groovy script also using this tool:

def wd = pluginHost.getWorkingDirectory()
def inputFile = wd + "input.shp"
def outputFile = wd + "output.shp"
def maxAngularDeviation = "30.0"
String[] args = [inputFile, outputFile, maxAngularDeviation]
pluginHost.runPlugin("FindStraightSegments", args, false)

Credits: