# Find polygon chains

The chain of polygons pattern is a characteristic pattern in which elongated and aligned polygons are arranged end-to-end. This pattern may arise because the lakes are confined to a fault line in the underlying bedrock or are controlled by streamlined landforms. This algorithm works by calculating the Minimum Bounding Box (MBB) for each vector polygon. If the MBB is sufficiently elongated, polygon end-points are identified for the feature. Each elongated polygon has two end points, which were defined as the polygon nodes nearest the two intersection points of the long-axis with the MBB. A nearest-neighbour analysis is then performed on each polygon end-point. End-points that are within a specified distance to the end-point of another polygon feature are then analyzed to determine if the two features are part of a chain. This involved comparing the relative distances between the four end-points of the two polygons and the lengths of the features. The tool can be made to only output chains of a specified minimum number of polygons. A second vector file can be optionally output to display the vector lines connecting the polygons within identified chains.

## 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" searchRadius = "1000.0" minChainSize = "3" chainFile = "not specified" args = [inputFile, outputFile, searchRadius, minChainSize, chainFile] pluginHost.runPlugin("FindPolygonChains", 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 searchRadius = "1000.0" def minChainSize = "3" def chainFile = wd + "chains.shp" String[] args = [inputFile, outputFile, searchRadius, minChainSize, chainFile] pluginHost.runPlugin("FindPolygonChains", args, false) ```

## Credits:

• John Lindsay (2013)