This can be used to identify the centroid point of a vector polyline or polygon feature or a group of vector points. The output is a vector shapefile of points. For multi-part polyline or polygon features, the user can optionally specify whether to identify the centroid of each part. The default is to treat multi-part features a single entity.
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]
# Notice that the multipart option is not specified and will default to 'false'
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"
def multipart = "true"
String[] args = [inputFile, outputFile, multipart]
pluginHost.runPlugin("Centroid", args, false)