How do I generate points at the intersection of the line with each polygon?

I need to generate points in the places where the line shape cuts to the shape of polygons. • 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 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.

-or-

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).

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

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 