1

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

here is the example case: enter image description here

here is the result: enter image description here

Bak
  • 411
  • 1
  • 5
  • 19
  • 1
    Maybe you could rewrite the query. First union the polygons to treat them as one. Then find linestrings that aren't fully covered by it. This can be figured out by comparing the length of the intersection with the length of the linestring itself. Then keep those parts which aren't covered by the polygon itself. – Timothy Dalton Aug 12 '23 at 04:35
  • 1
    thanks Timothy for the idea. I found this solution which solved my problem: https://gis.stackexchange.com/questions/155597/using-st-difference-to-remove-overlapping-features – Bak Aug 14 '23 at 01:10

0 Answers0