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

closed as off-topic by PolyGeo Dec 22 '18 at 4:21

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "When seeking help to debug/write/improve code always provide the desired behavior, a specific problem/error and the shortest code (as formatted text, not pictures) needed to reproduce it in the question body. Providing a clear problem statement and a code attempt helps others to help you." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 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.