I would like to cut my lines according to the polygon. And I want to keep only the cut lines that are outside the polygon. The cutting must be done at the intersections.
The result I get is not satisfactory because the lines are not cut properly at the intersections. Here is what I have already done:
select ST_SymDifference(ci.wkb_geometry,di.wkb_geometry )
from
(select st_union(ST_MakeValid(wkb_geometry)) as wkb_geometry from line) as ci
,
(
SELECT st_union(ST_MakeValid(ST_intersection(l.wkb_geometry, p.wkb_geometry))) as wkb_geometry
FROM line l, polygon p where ST_intersects(l.wkb_geometry, p.wkb_geometry)
) as di