6

In QGIS 3 I am trying to make a set of lines that are 50m to 2000m, at 50 meter intervals (e.g.: line 1 is 50m, line 2 is 100m, line 3 is 150m, etc).

I did it manually using the Advanced digitizing tool bar, but I would like to learn to do it more elegantly using the "Geometry by Expression" tool.

How do I use the "Geometry by Expression" tool to make a set of lines with a particular length interval using QGIS 3.x?

2
  • 2
    It might be simpler using the tool Vector Creation / array of offset lines or Vector Creation / array of translated features
    – JGH
    Jan 3, 2020 at 22:48
  • 4
    I think that with the Geometry by Expression algorithm you can return one output feature for each input feature. The output feature could contain a MultiLineString geometry, but overlapped parts make a non-OGC simple geometry. Seems to me better (and easier) perform that task with another method: a SQL query or a Python script. In any case: How would the starting point and azimuth be established? Jan 4, 2020 at 4:25

1 Answer 1

1

Starting from an original line (black), use the following expression with Geometry by expression to create lines with 50 m intervals (from 50 to 2000 m distance from the original line). This expression only generates lines to the left of the original line. To have lines on both sides, replace the first instance of 50 in line 3 by -2000 (see screenshot):

collect_geometries (
    array_foreach (
        generate_series (50,2000,50),
        offset_curve( $geometry, @element)
    )
)

The result is a multipart geometry. Run Menu Vector / Geometry Tools / Multipart to singleparts to get individual lines.

Screenshot, demonstrating the expression with Geometry generator: the red lines are created by the expression, based on the black line: enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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