This tool calculates the medoid for a series of vector features contained in shapefile. The medoid of a two-dimensional feature is conceptually similar its centroid, or mean position, but the medoid is always a members of the feature data set. Thus, the medoid is a measure of central tendency that is robust in the presence of outliers. If the input vector is of a POLYLINE or POLYGON ShapeType, the nodes of each feature will be used to estimate the feature medoid. If the input vector is of a POINT base ShapeType, the medoid will be calculated for the collection of points. While there are more than one competing method of calculating the medoid, this tool uses an algorithm that works as follows:

- The
*x*-coordinate and*y*-coordinate of each point/node are placed into two arrays. - The
*x*- and*y*-coordinate arrays are then sorted and the median*x*-coordinate () and median*Med X**y*-coordinate () are calculated.*Med Y* - The point/node in the dataset that is nearest the point (
,*Med X*) is identified as the medoid.*Med Y*

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

```
wd = pluginHost.getWorkingDirectory()
```

inputFile = wd + "input.shp"

outputFile = wd + "output.shp"

args = [inputFile, outputFile]

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

String[] args = [inputFile, outputFile]

pluginHost.runPlugin("Medoid", args, false)

- John Lindsay (2013), email: jlindsay@uoguelph.ca