I need to generate points in the places where the line shape cuts to the shape of polygons.enter image description here

  • 1
    The intersection of a line and a polygon is only a point if the line only touches the exterior. In the example shown, the intersections are lines, not points. You'd need to further process those lines to points, and then choose the right point. – Vince May 9 '19 at 16:47

As @Vince explained, the intersection of a line and a polygon is only a point if the line only touches the exterior. If the line crosses into and out of the polygon, the intersection is a line.

What you want is the intersection of the lines with the polygon boundaries. Here are two different ways to achieve this.

  1. Convert the polygons to lines, using the Polygons to lines tool. Take the intersection of the two line layers.


  1. Take the intersection of the lines and polygons (which gives you a layer of lines). Use the geometry by expression tool to extract the startpoints and endpoints of those lines. Run geometry by expression twice, once with this expression: start_point($geometry), and once with this one: end_point($geometry).
| improve this answer | |

you can use st_intersection between the line and the group of polygons, then your result will be this set of points you need.

| improve this answer | |

You can achieve what you want using a virtual layer.

Let's note that this approach assumes you have simple polygons only.

The idea is to compute the intersection between the line layer and the exterior ring of the polygons. Since both are lines you will typically end-up with a point at the intersection

Go to Layer / Add layer / Add-Edit virtual layer and enter the following expression

select st_intersection(l.geometry, st_exteriorring(a.geometry))
from myLineLayer l, myPolygonLayer a

enter image description here

| improve this answer | |

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.