This tool can be used to convert a vector file containing single-part features into a vector containing multi-part features. The user has the option to either group features based on an ID Field, which is a categorical field within the vector's attribute table, or to group all features together into one large multi-part vector. If all features are to be grouped then the ID Field should be set to 'merge all'. This tool works for vectors containing either point, line, or polygon features. Since shapefiles of a POINT ShapeType cannot represent multi-part features, the ShapeType of the output file will be modified to a MULTIPOINT ShapeType if the input file is of a POINT ShapeType. If the input vector is of a POLYGON ShapeType, the user can optionally set the algorithm to search for polygons that should be represented as hole parts. In the case of grouping based on an ID Field, hole parts are polygon features contained within larger polygons of the same ID value. Please note that searching for polygon holes may significantly increase processing time for larger polygon coverages.
To better understand the difference between multi-part and single-part vectors consider the following. The image below shows a vector coverage of Canada in which data are stored as a single record in a multi-part polygon. The attribute table only contains one entry.
In comparison, the following vector stores features as many individual single-part polygons. Each polygon is a seperate feature that possesses its own record in the attribute table.
The following is an example of a Python script that uses this tool:
wd = pluginHost.getWorkingDirectory()
inputFile = wd + "polygons.shp"
idField = "CLASS_ID"
outputFile = wd + "output.shp"
searchForHoles = "true"
args = [inputFile, idField, outputFile, searchForHoles]
pluginHost.runPlugin("SinglepartsToMultiparts", args, False)
This is a Groovy script also using this tool:
def wd = pluginHost.getWorkingDirectory()
def inputFile = wd + "lines.shp"
def idField = "merge all"
def outputFile = wd + "output.shp"
String[] args = [inputFile, idField, outputFile]
// searchForHoles need not be specified because the input vector does not contain polygons.
pluginHost.runPlugin("SinglepartsToMultiparts", args, false)