This tool takes a vector shapefile containing polygons, calculates the linearity (i.e. r-squared value) and orientation, and outputs a shapefile of line vectors. The vector associated with a polygon feature will be centered on the feature's centroid, its length will be proportional to its degree of linearity with a maximum length, for r-squared = 1, specified by the user), and oriented based on the slope of the trendline. Note that polygons are oriented (e.g. N-S, E-W, NE-SW, NW-SE) and that this orientation is expressed as an angle between 0 and 180 degrees clockwise from north. This algorithm works very well at finding the orientation of streamlined features. The output vector database will contain LINEARITY' and 'ORIENT' fields which record the vector's degree of linearity (r-squared of the regression trend line through its outline nodes) and orientation respectively. For effective visualization, select a line colour based on the 'ORIENT' field, use a circular palette such as 'pointer', and stretch the palette.
For most polygons, the results will be based on reduced major axis (RMA) regression line, although ordinary least-squares (OLS) regression is used when a polygon is nearly vertically or horizontally aligned. The user may opt to have the calculation based on the Elongation Ratio rather that the linearity index. If this option is selected, each patch orientation vector will be oriented along the polygon's long-axis, determined from the Minimum Bounding Box, with a length proportional to the long-axis, and centered on the middle point of the minimum bounding box. The corresponding entries in the database file will be names 'ELONGATION' and 'ELONG_DIR'.
The following is an example of a Python script that uses this tool:
wd = pluginHost.getWorkingDirectory()
inputFile = wd + "input.dep"
outputFile = wd + "output.dep"
maxLineLength = "100.0"
baseOnElongation = "true"
args = [inputFile, outputFile, maxLineLength, baseOnElongation]
pluginHost.runPlugin("PatchOrientationField", args, False)
This is a Groovy script also using this tool:
def wd = pluginHost.getWorkingDirectory()
def inputFile = wd + "input.dep"
def outputFile = wd + "output.dep"
def maxLineLength = "100.0"
def baseOnElongation = "true"
String args = [inputFile, outputFile, maxLineLength, baseOnElongation]
pluginHost.runPlugin("PatchOrientationField", args, false)