I have a 3d poly line and I want to create a cross section profile using this 3d lines.

What I want to achieve: I) Create vertices in the 'cross section line' where it intersects with the 3d poly line II) snap the heights from the 3d poly line into the 'cross section line' vertices

enter image description here


1 Answer 1


Result, visulized in 3D map view (red lines), based on your sample data:

enter image description here

How to achieve this:

  1. Split the lines where 3D Line and Cross_section_to_generate intersect. Use Menu Processing > Toolbox > Split with Lines. Set the 3D Line as Input and the other line layer as Split layer.

  2. Get the Z-value of the start-point of the new lines: these are the cross section points. Use QGIS expressions: z (start_point ($geometry))

enter image description here

If you need the points where lines cross with their z-values on a separate layer, continue as follows:

  1. On the layer created in step 2, create a new attribute names z_value with Field calculator and this expression: z (start_point ($geometry))

  2. Run Menu Processing > Toolbox > Geometry by expression, set the layer from step 3 as input, point as output geometry type and run it with this expression: start_point ($geometry).

White points with the interpolated z-value from the blue lines: enter image description here

Connect the points to lines (cross sections):

  1. Select the points lying on the lines of the layer Cross_section_to_generate, using select by expression with this expression: overlay_nearest ('Cross_section_to_generate', max_distance:=0.01) (this is to exclude points not lying on cross sections)

  2. Use Menu Processing > Toolbox > Points to path with the points as input.

    • Be sure to check to box Selected features only.
    • For Order expression, use line_locate_point ( overlay_nearest ('Cross_section_to_generate', $geometry)[0], $geometry) (the get the line in correct order).
    • For Path Group expression, use this expression overlay_nearest( 'Cross_section_to_generate', $id)[0].

    enter image description here

And here you are with your cross section. The line contains z-values for each vertex. To show the z-value, use z(point_n($geometry,[no])) where [no] should be replaced with the index of vertex (where 1 is the first vertex).

Reulst: red lines; z-values for start- end end-points appear in the labels: enter image description here

  • what I need is to create vertices on my cross section line where it interests with 3d line and insert z value of the 3d line into cross section vertices Aug 22, 2022 at 19:17
  • You didn't state that in your initial question. Please always make as clear as possible what you want to achieve - people here can't know. See updated answer, steps 3 and 4, for that.
    – Babel
    Aug 22, 2022 at 19:26
  • Thanks for the answer, it really helps me to find the correct tools and expressions. I have changed my question now, I hope now it explains well what i really want to do. Aug 23, 2022 at 11:42
  • OK, so how to understand that: did my answer solve your problem? Or did it not and in this case: what did not, what do you still miss?
    – Babel
    Aug 23, 2022 at 13:08
  • 1
    thanks a lot for the contribution. I didn't work on my own your steps. But it answered my question according to your updated answer 👍 Aug 25, 2022 at 19:44

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.