3

I'm relatively new to QGIS, I have past experience with ArcGIS.

I am trying to place 9 equally spaced points along a line, including one at each vertex. The points represent posts along a trellis wire in an orchard.

I have tried both the answers in this post... Creating specific amount of points along line in QGIS

  1. First I used "Points along geometry"; changing the 'Distance' to $length/9

  2. Next I used Geometry By Expression with the following code...

    with_variable ( 'no', 9, collect_geometries ( array_foreach ( generate_series (0,@no-1,1), line_interpolate_point( $geometry, length($geometry) / @no * @element ))))

My results are that 9 points are placed on each line, with a point on one vertex. However, I would like 9 points equally placed on each line with a point on both vertices.

Trellis Vectors Trellis Vector Attribute Table Results

  • QGIS version 3.22.10-Białowieża.
  • Windows 10.0.19044 Build 19044
  • Project Coordinate Reference System: EPSG: 2927 "NAD83 (HARN) / Washington South (ftUS)
  • Project Units: Feet
  • Layer Coordinate Reference System: Same as the project.
4
  • The vectors were generated from CAD drawing supplied by the architect who designed the orchard.
    – GNG85
    Feb 8, 2023 at 17:15
  • related: gis.stackexchange.com/questions/338026/…
    – JGH
    Feb 8, 2023 at 18:08
  • @JGH From the comments in the post you referenced; I set feet as default units for measurement both in Project > Properties > General > Measurements and Settings > Options > Map Tools > Measure Tool and tried again. I also tried running Points Along Geometry again with length($geometry) / 9 instead of length$ / 9. Last, I changed the Ellipsoid setting to None/Planimetric... The output is still the same
    – GNG85
    Feb 8, 2023 at 18:28
  • With your approach, I assume adding the geometry end_point to the geometry collection would have solved it
    – Kasper
    Feb 8, 2023 at 18:53

1 Answer 1

6

Try this geometry by expression. It will place 9 points along the line length. For some reason I had to subtract 0.0001 or some lines didnt get the end point.

collect_geometries(
array_foreach(
generate_series(0, $length, $length/8-0.0001),
line_interpolate_point( $geometry, @element)))

enter image description here

1
  • 1
    That solved the problem. Thank you. I will do some reading into you solution.
    – GNG85
    Feb 8, 2023 at 18:31

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.