2

I want to split a line with a specific value in QGIS. Can I also split the value proportionally to the length split?

I have some multiline strings that cross through multiple polygons. When I split the line I would like QGIS to also split the value assigned to the line accordingly. E.g. if a line of 100 meters has a value 20 when split into segments of 50/30/20 I want the value to also split to 10/6/4 in the corresponding segments. Is that possible or I am shooting for the stars?

1 Answer 1

2

You need to add the original $length of your line as an attribute, then split, and then you can divide your new length by the original one and multiply this by the value you want to "divide" between the segments.

E.g. $length / "field with original length" * "field with value".

3
  • Vince thank you for the reviewing :) Erik thank you for the response. However the problem is that I have to do this to a whole city (the lines are roads) so I was looking for maybe a way to iterate that process or if there is a function within the program that allows me to calculate these number. Any ideas on that?
    – Kyriakos
    Commented Mar 30, 2022 at 8:44
  • 1
    This can be done in the field calculator, obviously @Kyriakos.
    – Erik
    Commented Mar 30, 2022 at 9:07
  • 1
    Thank you! I got it now :)
    – Kyriakos
    Commented Mar 30, 2022 at 9:26

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.