[GIS] How to split line into specific number of parts

lineqgissplitting

I've seen a lot of questions involving splitting a line with the help of a point layer.

I want to split a line into fractions of its length.

For example, I have a line 400 meters long, I want to split it into four lines of 100 meters long each.

There is the grass module v.split, but I get an error message when I start it from the qgis toolbox :

*"TypeError: object of type 'NoneType' has no len()"*

So I'm not sure if I get it to work if this would be a solution.

Best Answer

The v.split.length function from GRASS should do exactly what you want by splitting the line into equal segments defined by the user without the need for a point layer. Here's a simple example of a straight line (it also works on non-straight and multiple lines):

Simple line

I added a column to calculate its length using $length in the expression:

Line attribute

Using the v.split.length function from GRASS via the Processing Toolbox, I chose to split the line into 25m segments which should make a total of 4 parts:

v.split.length function

I then updated the Length column of the output layer and used the same command as above to re-calculate the length:

Attribute result

Not sure why you are receiving the error, could you share your line layer for people to test?

Related Question