I am working with two vector layers in QGIS (location: Indonesia). I want to 'subtract' the area of layer 1 ('Forest_buffer') of layer 2 (Scenario_1). I am using the Difference algorithm. Layer 2 is the input layer, and layer 1 is the overlay layer.

I've used this algorithm before, but when I use layer 1 ('Forest_buffer'), the algorithm always fails after about 7%. The error I get says something about that a multilinestring can't be combined with a multipolygon layer:

"Object couldn't be written to Difference_19c76041_d4e5_4481_97ed_a76ef3cf8d3d: Could not add object of geometrytype MultiLineString to layer of MultiPolygon."

How to fix this? I already used the 'Fix geometries' on both layers, and the buffer trick. Both don't work. Could I perhaps somehow convert multilinestrings in the layer to polygons?

Here is the wetransfer link to the two data-sets: https://we.tl/t-gshlI4TbCU

Hopefully someone can help this QGIS beginner out!

  • Welcome to Geographic Information Systems! Welcome to GIS SE! We're a little different from other sites; this isn't a discussion forum but a Q&A site. Your questions should as much as possible describe not just what you want to do, but precisely what you have tried and where you are stuck trying that. Please check out our short tour for more about how the site works
    – Ian Turton
    May 18, 2021 at 10:25
  • You need to find and delete the MultiLineString
    – Ian Turton
    May 18, 2021 at 10:26
  • 1
    Dear Ian, Thank you for your response! How can I find and delete MultiLineStrings? It is quite a large data-set so by hand I can't identify them. I tried to use v.clean from grass. However, after a few minutes of running, QGIS doesn't respond anymore and I need to restart it. May 18, 2021 at 12:04
  • You can make a select filter based on the geometry type and then hit delete to delete the ones that match
    – Ian Turton
    May 18, 2021 at 12:42
  • 2
    @IanTurton, that's unfair. Both two source layers are polygons, they are valid, and the Vector overlay - Difference function has no option to filter out some type of geometries. Linestrings are returned by the algorithm that is saving them into a new layer but unfortunately QGIS can't handle the situation. I would say that it is impossible to do the task with these data with QGIS without changing something in the code. I am just making a test with OpenJUMP, let's see how it goes.
    – user30184
    May 18, 2021 at 13:26

1 Answer 1


I added an extra field with the $area (double, 6 digits) and deleting all values with less than 0. Because otherwise after editing there are only lines left in a multipolygon. This solved it for me.

Second time I saved the outcame as a geopackage layer and not as a temporary layer, because the shapefile can't contain a multipart (line/string/polygon). In the geopackage you can delete the line/string and save again as a shape.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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