QGIS – Creating Points Along Geometry in QGIS

qgis

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.

Best Answer

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

Related Question