3

I have what seems like a pretty straightforward task in QGIS: I have a shapefile that, in some cases, groups multiple separate landmasses into a single feature. For example, the Hawaiian islands are all one feature. How can I split those up into multiple features? This seems like it should be easy but it's proving impossible.

Using the "Split Feature" tool doesn't do anything when I try to draw a split line between the islands, or surround one of them. The "Singlepart to Multipart" option in the vector tools might do the job, but it's not selective, it just splits up EVERY multipart feature, when I only want to split up a few of them.

How can I pick a polygon that's one part of a multipart feature, like a single island in a chain, and split that out as a separate feature?

  • "Singlepart to multipart" is the opposite of what you want to accomplish. – user3461 Jun 30 '13 at 15:56
  • Yes, sorry, I meant the opposite. Regardless, it doesn't do what I need, which is to SELECTIVELY split features. – NChase Jun 30 '13 at 20:03
3

As geoKevin said look got Multipart to Singlepart in the Vector menu.

enter image description here

  • Yes, that doesn't do what I need, which is to be able to choose a feature to split rather than to automatically split all of them. – NChase Jun 30 '13 at 20:04
3

I found a script on the osgeo forum that will explode any selected multipart features to singlepart in QGIS 1.8 (I assume it will still work in current versions).

Credit for this script goes to Alexandre Neto, the author of the first message at that link.

layer = qgis.utils.iface.mapCanvas().currentLayer()
remove_list = []

for feature in layer.selectedFeatures():
    geom = feature.geometry()
    # check if feature geometry is multipart
    if geom.isMultipart():
        remove_list.append(feature.id())
        new_features = []
        temp_feature = QgsFeature(feature)
        # create a new feature using the geometry of each part
        for part in geom.asGeometryCollection ():
            temp_feature.setGeometry(part)
            new_features.append(QgsFeature(temp_feature))
        # add new features to layer
        layer.addFeatures(new_features, False)

# remove the original (multipart) features from layer
if len(remove_list) > 0:
    for id in remove_list:
        layer.deleteFeature (id)

Turns out the author posted the same thing here on GIS SE, and was able to turn the tool into a plugin.

  • 1
    The plugin is working in 1.8, but not in the latest master versions. That's because I did not had the time to change it to the new QGIS 2.0 API. Will do it as soon as I can. – Alexandre Neto Jul 1 '13 at 9:44
1

As has been suggested Multipart to singleparts is what you are looking for. In order to selectively apply it to some features, you may want to check the field "Selected features only"enter image description here (be sure to have some features selected first).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.