Centroid (vector)

This can be used to identify the centroid point of a vector polygon or polyline feature. The output is a vector shapefile of points.

See Also:

Scripting:

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

wd = pluginHost.getWorkingDirectory()
inputFile = wd + "polygons.shp"
outputFile = wd + "output.shp"
args = [inputFile, outputFile]
pluginHost.runPlugin("Centroid", args, False)

This is a Groovy script also using this tool:

def wd = pluginHost.getWorkingDirectory()
def inputFile = wd + "polygons.shp"
def outputFile = wd + "output.shp"
String[] args = [inputFile, outputFile]
pluginHost.runPlugin("Centroid", args, false)

Credits: