This tool can be used to calculate the fractal dimension (Mcgarigal et al. 2002) for polygons. It will work 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 fractal dimension will be assigned to each feature in the input file), the specified option of outputting text, and whether or not zero values should be treated as background values. If a vector shapefile is specified as the input file, the only required input is the name of the file. The fractal dimension values calculated for each vector polygon feature will be placed in the accompanying database file (.dbf) as a fractal dimension field (FRACTAL_D). The resulting database file will be automatically displayed after the tool has completed.

The fractal dimension (*F*) is:
`F = 2lnP / lnA`

Where *P* is the
polygon's perimeter, *A* is its area, and *ln* is the
natural logarithm. For raster-based perimeter estimation, the tool
uses the accurate, anti-aliasing algorithm of Prashker (2009).

Theoretically, *F* approaches 1 for shapes with very simple
boundaries, such as circles, and approaches 2 for shapes with highly
convoluted, plane-filling boundaries. In practice, however, *F*
tends to display a very restricted range of values for a wide
variety of shapes. For many applications, the
** Shape Complexity Index**
is better suited to expressing polygon irregularity and overall
shape complexity.

- John Lindsay (2012)

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

zerosAreBackground = "false" # also ignored

args = [inputFile, outputFile, textOutput, zerosAreBackground]

pluginHost.runPlugin("FractalDimension", 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"

def zerosAreBackground = "true"

String[] args = [inputFile, outputFile, textOutput, zerosAreBackground]

pluginHost.runPlugin("FractalDimension", args, False)

- Mcgarigal, K., Cushman, S. A., Neel, M. C., & Ene, E. (2002). FRAGSTATS: spatial pattern analysis program for categorical maps.
- Prashker, S. (2009) An anti-aliasing algorithm for calculating the perimeter of raster polygons. Geotec, Ottawa & Geomtics Atlantic, Wolfville, NS.