I am trying to merge two linestrings/Lines/Polylines (not sure actually how I can see the difference whether my layer is a Linestring/Line or Polyline and googling didn't really brought clarification).

When I try to merge them (I tried with the MMQGIS 'Merge layers' function as well as with 'Data management Tools' -> 'Merge Shapefiles to one') I get an error saying that the geometry types need to be the same.

This is what I've tried so far:

  1. I tried the 'Multiparts to Singleparts' option on both of them and tried to merge them
  2. I tried to save both of them with the LineString as geometry type and with the Z-dimension bocks ticked off and merging the results
  3. I tried to export them as a CSV and manuallymerging the data in one excel document that I tried to upload again (failed since it can't find coordinates)

(these three are worked out here: Error in merging 2 shape files of different geometry types) 4. Finally I tried the Dissolve tool after which I tried to merge the result.

All of this without result. Probably I'm just overlooking something very easy. I hope someone can shine his/her light on this and help me out with it. I attach a photo of the Two Linestrings as well as their Attribute Table.



enter image description here

enter image description here


Since MMQGIS fails because "the geometry types need to be the same", you may try to convert all the layers to lines before running the plugin.

It could help using the Convert geometry type algorithm from the Processing Toolbox (the name is self-explanatory). You may try to convert both layers to LineString, so they will be of the same geometry type.

As an additional test, you may also select a layer from the Layers Panel and then run this simple code from the Python Console:

print layer.wkbType()

This will print a number which defines the geometry type of your layer: if the print returns 2, your layer is a Linestring; if the print returns 5, the layer is a MultiLineString (you may try to run the above code before and after the execution of the algorithm for seeing the difference).

You may find some useful information about the formal definition of Linestring and MultiLineString from this document of the OGC® Standards (pp. 22-25).

  • I tried converting the geometry type to Linestrings through "Convert geometry type" as you proposed, but again without success. When running the code on the Python Console it returned the value 2 for one layer and the value -2147483646 for the other. (I added a screenshot of this to the initial question) – mathias dhaen Feb 24 '17 at 5:47
  • @mathiasdhaen that's weird, I never saw that value :) You may do another attempt by directly running the Merge vector layers SAGA tool from Processing – mgri Feb 24 '17 at 7:48
  • @mathiasdhaen Perhaps there is some corruption in the file returning the weird value. Try creating a new shapefile and copy / paste the features in the new file. – Techie_Gus Feb 24 '17 at 8:40

I finally found the solution to this problem. I first made sure both layers were a Linestring through "Convert Geometry Type", saved both linestrings as a KML and merged them with the MMQGIS option, after which I saved it again as a Shapefile.

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.