3

I have a center line and an intersection point. I want to create points on either side of this intersection point along the center line with an interval 50 meters(can vary) starting from the intersection point. I tried "Points along geometry" which didn't give desired result in QGIS.

enter image description here

When I split the line proceed with "points along geometry" I get the points which are not at 50m interval from the intersection. In the image below the distance between the highlighted points is not 50m

enter image description here

I want something like creating points on either side with negative chainages on one side and positive on the other, so that I can clearly identify the points after exporting them to csv.

6
  • Could you specify, how your "points along geometry" did not yield the desired result? If you want the points to start exactly at the intersection, maybe split the line with your 'river line' and then perform "points along geometry" on these 2 resulting lines.
    – Vincé
    Mar 3 at 10:38
  • As shown in the image above points are at 50 m interval on either side.
    – Sharma ND
    Mar 3 at 11:23
  • 2
    That is because the points are being interpolated from the other end of the line. You will need to reverse that part of the center line first. Processing Toolbox -> Vector Geometry -> Reverse line direction
    – Matt
    Mar 3 at 11:24
  • You mean to say that, I need to select the parts of the split lines of each center line from a series of center lines, reverse them and perform "Points Along Geometry". As you can see it is not one line that I have. There are several other lines too.
    – Sharma ND
    Mar 3 at 11:44
  • Points along geometry works in the direction the line was drawn. It would appear that your line was drawn northwest-southeast. When you split the line, the two parts are still northwest-southeast. To get Points along geometry to start at your intersection point for the westmost line, you will need to reverse the direction of that line, so it goes southeast-northwest.
    – Matt
    Mar 3 at 11:50

1 Answer 1

0

The idea

Use the following expression on the line layer with Geometry by expression or Geometry generator (see here for details) and make setting accordingly:

  • Replace intersection (line 3) with the name of the point layer containing the intersections.
  • Replace the distance of the interval for the points to be created in line 6.

Possible variants:

  • If creating actual points using Geometry by expression, you get multipart geometries. Convert them to single points using Menu Vector / Geomtry tools / Multipart to single parts.
  • This expression creates points along the whole length of the line. To create only a limited no. of points, see at the bottom.

The expression to use:

with_variable (
    'inter',
    'intersection',
    with_variable (
        'distance',
        100,
        collect_geometries (
            array_foreach (
                generate_series (
                    floor(
                        line_locate_point( 
                            $geometry,
                            overlay_nearest (
                                @inter,
                                $geometry
                            )[0]
                        )/-@distance
                    )+1,
                    floor (
                        (length ($geometry)-
                        line_locate_point( 
                            $geometry,
                            overlay_nearest (
                                @inter,
                                $geometry
                            )[0]
                        ))/@distance
                    )
                ),
                line_interpolate_point( 
                    $geometry, 
                    line_locate_point( 
                        $geometry,
                        overlay_nearest (
                            @inter,
                            $geometry
                        )[0]
                    )+@distance*@element
                )
            )
        )
    )
)

Expression used with Geomtry generator, creating points on both sided of the blue intersection points at a regular distance of 50 m along the line: enter image description here

Create only a limited no. of points

To create only a limited no. of points, change the above expression. Replace the generate_series () part (lines 9 to 29) with this expression: generate_series (-5,3), where 5 (preceded by a minus!) is the no. of points between the intersection and the start-point of the line, 3 is the no. of points from the intersection towards the line's end-point.

Be aware: if one of the lines is too short to accommodate all points you want to create, no points at all will be created. In this case, decrease the numbers.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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