I want to select lines that only touch both sides of a polygon. Is there a function in postgis that can do this? See image below. I only want to select lines from the circle on the left where the line touches both sides of the polygon.
I would say that to fit your description, the line should be :
- Completely inside the polygon
- Have its start and end points touching the boundary of the polygon
SELECT line_id, geom FROM line a JOIN polygon b ON ST_Within(a.geom,b.geom) AND ST_Intersects(ST_StartPoint(a.geom),ST_Boundary(b.geom)) AND ST_Intersects(ST_EndPoint(a.geom),ST_Boundary(b.geom))