Linearity index

This tool calculates the linearity index of polygon features based on a regression analysis. The index is simply coefficient of determination (r2) calculated from a regression analysis of the x and y coordinates of either all of the grid cells within a polygon (in the case of a raster input) or the exterior hull nodes of a vector polygon. Linearity index is a measure of how well a polygon can be described by a straight line. It is a related index to the Elongation Ratio, but is much more efficient to calculate as it does not require finding the Minimum Bounding Box. Also, linearity can be calculated for raster data, whereas the elongation ratio tool only accepts vector inputs. The Pearson correlation coefficient between linearity index and the elongation ratio for a large data set of lake polygons in northern Canada was found to be 0.656, suggesting a moderate level of association between the two measures of polygon linearity. Note that this index is not useful for identifying narrow yet sinuous polygons, such as meandering rivers.

The tool works for either raster or vector input files. If a raster file is input, the grid should contain polygons with unique identifiers. Raster input files also require the name of the output raster file (where the linearity will be assigned to each feature in the input file) and the specified option of outputting text. If a vector shapefile is specified as the input file, the only required input is the name of the file. The linearity values calculated for each vector polygon feature will be placed in the accompanying database file (.dbf) as a new field (LINEARITY). The resulting database file will be automatically displayed after the tool has completed.

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.

See Also:

Scripting:

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

wd = pluginHost.getWorkingDirectory()
inputFile = wd + "polygons.shp" # vector input
outputFile = "" # ignored for vector input
textOutput = "false" # also ignored
args = [inputFile, outputFile, textOutput]
pluginHost.runPlugin("LinearityIndex", args, False)

This is a Groovy script also using this tool:

def wd = pluginHost.getWorkingDirectory()
def inputFile = wd + "polygons.dep" // raster input
def outputFile = wd + "output.dep"
def textOutput = "true"
String[] args = [inputFile, outputFile, textOutput]
pluginHost.runPlugin("LinearityIndex", args, False)

Credits: