I have one shapefile that contains two parallel lines in yellow in the picture. Both lines have the same feature (these lines were originally both sides of a fixed distance buffer around a line). I clipped that buffer to create two "borders" within a third polygon (one administrative unit). My goal is to split that shapefile into two shapefiles OR to give a different ID to each line so I can subsequently work with them. In a nutshell, these two lines represent boundaries, a northern boundary and a southern boundary.

These lines are not of the same length.

I am looking for a python command.


enter image description here

enter image description here

  • 1
    If these lines are identical in length then you could use pyqgis to search for like length features and then export each to separate shp. Update your question with a code attempt and then I can further assist. – artwork21 Dec 20 '18 at 17:09
  • @artwork21 No these two lines are not identical in length. Let me update my question. – Marcel Campion Dec 20 '18 at 17:15

You have a multipart polyline (two line but with only one set of attribute) if you run the "Multipart to singleparts" tool (from the processing toolbox) you will get two line with the same attribut but a different ID

enter image description here

Another way to go is to toggle editing and use the "Split Parts" editing tool from the edit toolbar. enter image description here

After that you could export each line to separate shapefile if you need

If you really need a python solution search this site with "Multipart to singleparts" and "python" keywords, you'll probably find some answer.

  • processing.runalg("qgis:multiparttosingleparts","input.shp","output.shp") – Marcel Campion Dec 20 '18 at 17:31

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